lib/alba/many.rb in alba-0.9.0 vs lib/alba/many.rb in alba-0.10.0
- old
+ new
@@ -1,12 +1,12 @@
require 'alba/association'
module Alba
# Representing many association
class Many < Association
- def to_hash(target)
+ def to_hash(target, params: {})
objects = target.public_send(@name)
- @resource ||= resource_class
- objects.map { |o| @resource.new(o).to_hash }
+ objects = @condition.call(objects) if @condition
+ objects.map { |o| @resource.new(o, params: params).to_hash }
end
end
end