Module: Dynamoid::Associations::ClassMethods

Defined in:
lib/dynamoid/associations.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) belongs_to(name, options = {})

create a belongs_to association for this document.

Parameters:

  • name (Symbol)

    the name of the association

  • options (Hash) (defaults to: {})

    options to pass to the association constructor

Options Hash (options):

  • :class (Class)

    the target class of the has_one association; that is, the has_many or has_one class

  • :class_name (Symbol)

    the name of the target class of the association; that is, the name of the has_many or has_one class

  • :inverse_of (Symbol)

    the name of the association on the target class; that is, if the class has a has_many or has_one association, the name of that association

Since:

  • 0.2.0



64
65
66
# File 'lib/dynamoid/associations.rb', line 64

def belongs_to(name, options = {})
  association(:belongs_to, name, options)
end

- (Object) has_and_belongs_to_many(name, options = {})

create a has_and_belongs_to_many association for this document.

Parameters:

  • name (Symbol)

    the name of the association

  • options (Hash) (defaults to: {})

    options to pass to the association constructor

Options Hash (options):

  • :class (Class)

    the target class of the has_and_belongs_to_many association; that is, the belongs_to class

  • :class_name (Symbol)

    the name of the target class of the association; that is, the name of the belongs_to class

  • :inverse_of (Symbol)

    the name of the association on the target class; that is, if the class has a belongs_to association, the name of that association

Since:

  • 0.2.0



77
78
79
# File 'lib/dynamoid/associations.rb', line 77

def has_and_belongs_to_many(name, options = {})
  association(:has_and_belongs_to_many, name, options)
end

- (Object) has_many(name, options = {})

create a has_many association for this document.

Parameters:

  • name (Symbol)

    the name of the association

  • options (Hash) (defaults to: {})

    options to pass to the association constructor

Options Hash (options):

  • :class (Class)

    the target class of the has_many association; that is, the belongs_to class

  • :class_name (Symbol)

    the name of the target class of the association; that is, the name of the belongs_to class

  • :inverse_of (Symbol)

    the name of the association on the target class; that is, if the class has a belongs_to association, the name of that association

Since:

  • 0.2.0



38
39
40
# File 'lib/dynamoid/associations.rb', line 38

def has_many(name, options = {})
  association(:has_many, name, options)
end

- (Object) has_one(name, options = {})

create a has_one association for this document.

Parameters:

  • name (Symbol)

    the name of the association

  • options (Hash) (defaults to: {})

    options to pass to the association constructor

Options Hash (options):

  • :class (Class)

    the target class of the has_one association; that is, the belongs_to class

  • :class_name (Symbol)

    the name of the target class of the association; that is, the name of the belongs_to class

  • :inverse_of (Symbol)

    the name of the association on the target class; that is, if the class has a belongs_to association, the name of that association

Since:

  • 0.2.0



51
52
53
# File 'lib/dynamoid/associations.rb', line 51

def has_one(name, options = {})
  association(:has_one, name, options)
end