Class: Yogo::Collection::Relationship
Defined Under Namespace
Classes: ManyToMany, ManyToOne, OneToMany, OneToOne
Constant Summary
Constants inherited
from Property
Property::COMMON_PROPERTIES
Instance Method Summary
collapse
Methods inherited from Property
#field_name, #to_s, #update_attributes
Instance Method Details
#add_to_model(model, n, options = {}) ⇒ Object
91
92
93
94
|
# File 'lib/yogo/collection/property.rb', line 91
def add_to_model(model, n, options={})
check_target
model.send(model_method, n, ActiveSupport::Inflector.tableize(self.target).intern, options.merge(self.options))
end
|
#as_json(options = nil) ⇒ Object
73
74
75
76
77
|
# File 'lib/yogo/collection/property.rb', line 73
def as_json(options=nil)
hash = super
hash[:target_collection_id] = self.target_collection_id.to_s
hash
end
|
#check_target ⇒ Object
87
88
89
|
# File 'lib/yogo/collection/property.rb', line 87
def check_target
raise ":target not set" unless self.target && !self.target.empty?
end
|
#model_method ⇒ Object
83
84
85
|
# File 'lib/yogo/collection/property.rb', line 83
def model_method
:has
end
|
#target_model ⇒ Object
79
80
81
|
# File 'lib/yogo/collection/property.rb', line 79
def target_model
target_collection.data_model
end
|