Sha256: 9df07a88013b8880a73bf5a9e96b2283a03848ba05f657b6194c6782895de7be
Contents?: true
Size: 1.27 KB
Versions: 11
Compression:
Stored size: 1.27 KB
Contents
module Restly::EmbeddedAssociations::ClassMethods private # Embeds One def embeds_resource(name, options = {}) exclude_field(name) if ancestors.include?(Restly::Base) self.resource_associations[name] = association = Restly::EmbeddedAssociations::EmbedsOne.new(self, name, options) define_method name do |options={}| return get_association(name) if get_association(name).present? set_association name, association.stub(self) end define_method "#{name}=" do |value| set_association name, value end end # Embeds Many def embeds_resources(name, options = {}) exclude_field(name) if ancestors.include?(Restly::Base) self.resource_associations[name] = association = Restly::EmbeddedAssociations::EmbedsMany.new(self, name, options) define_method name do |options={}| get_association(name, options) end define_method "#{name}=" do |value| set_association name, value end end def embedded_in(name, options={}) self.resource_associations[name] = association = Restly::EmbeddedAssociations::EmbeddedIn.new(self, name, options) define_method name do |options={}| get_association(name, options) end define_method "#{name}=" do |value| set_association name, value end end end
Version data entries
11 entries across 11 versions & 1 rubygems