Sha256: 05f1e7b447c8e8f907dba2df230645c804a0686a808a701fbecdef4d453c61fb
Contents?: true
Size: 856 Bytes
Versions: 3
Compression:
Stored size: 856 Bytes
Contents
module Restly::Associations::Base::Builders # Build def build(parent, attributes = nil, options = {}) # Merge Options options.reverse_merge!(self.options) # Authorize and Set Path association = authorize(options[:authorize]).with_path(parent, options[:path]) collection? ? association.build_collection(parent) : association.build_instance(parent, attributes) end private def build_instance(parent, attributes) instance = association_class.new(attributes, options) instance.write_attribute("#{@owner.resource_name}_id", parent.id) if association_class.method_defined?("#{@owner.resource_name}_id") Restly::Proxies::Associations::Instance.new(instance, parent) end def build_collection(parent) Restly::Proxies::Associations::Collection.new(Restly::Collection.new(association_class), parent) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
restly-0.0.1.alpha.8 | lib/restly/associations/base/builders.rb |
restly-0.0.1.alpha.7 | lib/restly/associations/base/builders.rb |
restly-0.0.1.alpha.6 | lib/restly/associations/base/builders.rb |