lib/surrealist/value_assigner.rb
# Assigns value returned from a method to a corresponding key in the schema hash.
#
# @param [Object] instance the instance of the object which methods from the schema are called on.
# @param [Struct] schema containing a single schema key and value
#
# @return [Hash] schema
Assigns value returned from a method to a corresponding key in the schema hash.
Assigns value returned from a method to a corresponding key in the schema hash .
def assign(schema, instance)
        value = raw_value(instance, schema)
        @skip_set ||= Set.new
        if value.respond_to?(:build_schema)
          yield assign_nested_record(instance, value)
        elsif Helper.collection?(value) && !value.empty? && value.all? { |v| Helper.surrealist?(v.class) }
          yield assign_nested_collection(instance, value)
        else
          yield value
        end
      end
def assign ( schema , instance ) value = raw_value ( instance , schema ) @skip_set ||= Set . new if value . respond_to? ( :build_schema ) yield assign_nested_record ( instance , value ) elsif Helper . collection? ( value ) && ! value . empty? && value . all? { | v | Helper . surrealist? ( v . class ) } yield assign_nested_collection ( instance , value ) else yield value end end
Assigns value returned from a method to a corresponding key in the schema hash.
Assigns value returned from a method to a corresponding key in the schema hash .
# set to track and prevent infinite self references in surrealization
None
Hash
schema
<not_specific>
instance
<not_specific>
<not_specific>
schema containing a single schema key and value
schema containing a single schema key and value