Sha256: 58d1e54b1f63c635c3c8ea05758c355b366e78886d3354adf5fd8b02b2789a74
Contents?: true
Size: 555 Bytes
Versions: 3
Compression:
Stored size: 555 Bytes
Contents
require_relative 'association' module Alba # Representing many association class Many < Association # Recursively converts objects into an Array of Hashes # # @param target [Object] the object having an association method # @param params [Hash] user-given Hash for arbitrary data # @return [Array<Hash>] def to_hash(target, params: {}) objects = target.public_send(@name) objects = @condition.call(objects, params) if @condition objects.map { |o| @resource.new(o, params: params).to_hash } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
alba-0.13.0 | lib/alba/many.rb |
alba-0.12.0 | lib/alba/many.rb |
alba-0.11.1 | lib/alba/many.rb |