Class: Relationships::HasMany

Inherits:
Relationship show all
Defined in:
lib/active_mocker/active_record/relationships.rb

Instance Attribute Summary collapse

Attributes inherited from Relationship

#name

Instance Method Summary collapse

Methods inherited from Relationship

#class_name, #join_table, #options, #through

Constructor Details

#initialize(name, klass_name, options = {}) ⇒ HasMany

Returns a new instance of HasMany.



60
61
62
63
# File 'lib/active_mocker/active_record/relationships.rb', line 60

def initialize(name, klass_name, options={})
  @klass_name = klass_name
  super(name, options)
end

Instance Attribute Details

#klass_nameObject (readonly)

Returns the value of attribute klass_name.



58
59
60
# File 'lib/active_mocker/active_record/relationships.rb', line 58

def klass_name
  @klass_name
end

Instance Method Details

#foreign_keyObject



65
66
67
# File 'lib/active_mocker/active_record/relationships.rb', line 65

def foreign_key
  options[:foreign_key] || klass_name.to_s.foreign_key
end