Sha256: b70520b4789cf6dca52f3c9bd7c17be97d899bcaabb820c0064531a947dbd9c3
Contents?: true
Size: 759 Bytes
Versions: 3
Compression:
Stored size: 759 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 within [Hash] determines what associations to be serialized. If not set, it serializes all associations. # @param params [Hash] user-given Hash for arbitrary data # @return [Array<Hash>] def to_hash(target, within: nil, params: {}) @object = target.public_send(@name) @object = @condition.call(@object, params) if @condition return if @object.nil? @resource = constantize(@resource) @resource.new(@object, params: params, within: within).to_hash end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
alba-1.5.0 | lib/alba/many.rb |
alba-1.4.0 | lib/alba/many.rb |
alba-1.3.0 | lib/alba/many.rb |