Sha256: 6bb6e1e4cc248580a292f156c31ca65e56f1657417337c426ee85b7dcf0849c8
Contents?: true
Size: 591 Bytes
Versions: 2
Compression:
Stored size: 591 Bytes
Contents
require_relative 'association' module Alba # Representing one association class One < Association # Recursively converts an object into a Hash # # @param target [Object] the object having an association method # @param params [Hash] user-given Hash for arbitrary data # @return [Hash] def to_hash(target, 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).to_hash end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
alba-1.0.1 | lib/alba/one.rb |
alba-1.0.0 | lib/alba/one.rb |