lib/alba/one.rb in alba-0.11.0 vs lib/alba/one.rb in alba-0.11.1

- old
+ new

@@ -1,9 +1,14 @@ -require 'alba/association' +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 @resource.new(object, params: params).to_hash end