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.



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

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.



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

def config
  @config
end

#configurationObject (readonly)

Returns the value of attribute configuration.



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

def configuration
  @configuration
end

#formattersObject (readonly)

Returns the value of attribute formatters.



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

def formatters
  @formatters
end

#handlersObject (readonly)

Returns the value of attribute handlers.



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

def handlers
  @handlers
end

#payloadObject (readonly)

Returns the value of attribute payload.



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

def payload
  @payload
end

Instance Method Details

#resolve(payload) ⇒ Object



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

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