Sha256: 055edfb489be84e4f82fab2c85051fc73724d0dada79b2a357dea676f586f76e
Contents?: true
Size: 585 Bytes
Versions: 1
Compression:
Stored size: 585 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 return if objects.nil? objects.map { |o| @resource.new(o, params: params).to_hash } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alba-0.13.1 | lib/alba/many.rb |