Class: PayloadTranslator::FieldResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/payload_translator/field_resolver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field_config, configuration) ⇒ FieldResolver

Returns a new instance of FieldResolver.



6
7
8
9
10
11
# File 'lib/payload_translator/field_resolver.rb', line 6

def initialize(field_config, configuration)
  @configuration = configuration
  @handlers = configuration.handlers
  @formatters = configuration.formatters
  @config = field_config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



4
5
6
# File 'lib/payload_translator/field_resolver.rb', line 4

def config
  @config
end

#configurationObject (readonly)

Returns the value of attribute configuration.



4
5
6
# File 'lib/payload_translator/field_resolver.rb', line 4

def configuration
  @configuration
end

#formattersObject (readonly)

Returns the value of attribute formatters.



4
5
6
# File 'lib/payload_translator/field_resolver.rb', line 4

def formatters
  @formatters
end

#handlersObject (readonly)

Returns the value of attribute handlers.



4
5
6
# File 'lib/payload_translator/field_resolver.rb', line 4

def handlers
  @handlers
end

#payloadObject (readonly)

Returns the value of attribute payload.



4
5
6
# File 'lib/payload_translator/field_resolver.rb', line 4

def payload
  @payload
end

Instance Method Details

#resolve(payload) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/payload_translator/field_resolver.rb', line 13

def resolve(payload)
  @payload = payload
  if is_a_array?
    resolve_array
  elsif deep_object?
    resolve_deep_object
  elsif config["$fnc"]
    resolve_fnc
  elsif config["$map"]
    resolve_map
  else
    resolve_value
  end
end