Class: Relationships::Relationship
- Inherits:
-
Object
- Object
- Relationships::Relationship
show all
- Defined in:
- lib/active_mocker/active_record/relationships.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name, options = {}) ⇒ Relationship
Returns a new instance of Relationship.
30
31
32
33
|
# File 'lib/active_mocker/active_record/relationships.rb', line 30
def initialize(name, options={})
@name = name
@options = options.reduce(HashWithIndifferentAccess.new, :merge)
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
29
30
31
|
# File 'lib/active_mocker/active_record/relationships.rb', line 29
def name
@name
end
|
Instance Method Details
#class_name ⇒ Object
43
44
45
|
# File 'lib/active_mocker/active_record/relationships.rb', line 43
def class_name
options[:class_name] || name.to_s.camelize.singularize
end
|
#foreign_key ⇒ Object
47
48
49
|
# File 'lib/active_mocker/active_record/relationships.rb', line 47
def foreign_key
options[:foreign_key] || name.to_s.foreign_key
end
|
#join_table ⇒ Object
51
52
53
|
# File 'lib/active_mocker/active_record/relationships.rb', line 51
def join_table
options[:join_table]
end
|
#options ⇒ Object
35
36
37
|
# File 'lib/active_mocker/active_record/relationships.rb', line 35
def options
@options.symbolize_keys
end
|
#through ⇒ Object
39
40
41
|
# File 'lib/active_mocker/active_record/relationships.rb', line 39
def through
options[:through]
end
|