Module: Mutils::Serialization::Results::Attributes

Included in:
SerializationResults
Defined in:
lib/mutils/serialization/results/attributes.rb

Overview

Module Attributes

Instance Method Summary collapse

Instance Method Details

#fetch_attributes(attributes, result_hash) ⇒ Object



19
20
21
22
23
# File 'lib/mutils/serialization/results/attributes.rb', line 19

def fetch_attributes(attributes, result_hash)
  attributes&.each do |key, s_options|
    check_if_included(s_options, key) && (result_hash[key] = s_options[:method] ? send(key) : scope.send(key))
  end
end

#fetch_block_attributes(attributes, result_hash) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/mutils/serialization/results/attributes.rb', line 10

def fetch_block_attributes(attributes, result_hash)
  attributes&.each do |key, s_options|
    arg = [scope]
    (arg << options[:params]) || {} unless s_options[:block].parameters.flatten.include?(:rest)

    result_hash[key] = s_options[:block].call(*arg)
  end
end