lib/restly/associations/base/stubs.rb in restly-0.0.1.alpha.8 vs lib/restly/associations/base/stubs.rb in restly-0.0.1.alpha.9
- old
+ new
@@ -4,13 +4,17 @@
def stub(parent, attributes)
return nil if !parent.is_a?(Restly::Base) || !attributes.present?
collection? ? stub_collection(parent, attributes) : stub_instance(parent, attributes)
end
- private
-
def stub_collection(parent, attributes)
- collection = attributes.map{ |item_attrs| association_class.new(item_attrs, loaded: embedded?) }
+ collection = attributes.map do |item|
+ if item.respond_to? :attributes
+ item
+ else
+ association_class.new(item, loaded: embedded?)
+ end
+ end
Restly::Proxies::Associations::Collection.new(collection, parent)
end
def stub_instance(parent, attributes)
instance = association_class.new(attributes, loaded: embedded?)
\ No newline at end of file