Module: Dynamoid::Associations::Association

Included in:
HasOne, ManyAssociation, SingleAssociation
Defined in:
lib/dynamoid/associations/association.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/dynamoid/associations/association.rb', line 10

def name
  @name
end

#optionsObject

Returns the value of attribute options.



10
11
12
# File 'lib/dynamoid/associations/association.rb', line 10

def options
  @options
end

#sourceObject

Returns the value of attribute source.



10
11
12
# File 'lib/dynamoid/associations/association.rb', line 10

def source
  @source
end

Instance Method Details

#initialize(source, name, options) ⇒ Dynamoid::Association

Create a new association.

Parameters:

  • source (Class)

    the source record of the association; that is, the record that you already have

  • name (Symbol)

    the name of the association

  • options (Hash)

    optional parameters for the association

Options Hash (options):

  • :class (Class)

    the target class of the association; that is, the class to which the association objects belong

  • :class_name (Symbol)

    the name of the target class of the association; only this or Class is necessary

  • :inverse_of (Symbol)

    the name of the association on the target class

  • :foreign_key (Symbol)

    the name of the field for belongs_to association

Returns:

  • (Dynamoid::Association)

    the actual association instance itself

Since:

  • 0.2.0



27
28
29
30
31
32
# File 'lib/dynamoid/associations/association.rb', line 27

def initialize(source, name, options)
  @name = name
  @options = options
  @source = source
  @loaded = false
end