Class: PayloadTranslator::FieldResolver
- Inherits:
-
Object
- Object
- PayloadTranslator::FieldResolver
- Defined in:
- lib/payload_translator/field_resolver.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#formatters ⇒ Object
readonly
Returns the value of attribute formatters.
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Instance Method Summary collapse
-
#initialize(field_config, configuration) ⇒ FieldResolver
constructor
A new instance of FieldResolver.
- #resolve(payload) ⇒ Object
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
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/payload_translator/field_resolver.rb', line 4 def config @config end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
4 5 6 |
# File 'lib/payload_translator/field_resolver.rb', line 4 def configuration @configuration end |
#formatters ⇒ Object (readonly)
Returns the value of attribute formatters.
4 5 6 |
# File 'lib/payload_translator/field_resolver.rb', line 4 def formatters @formatters end |
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
4 5 6 |
# File 'lib/payload_translator/field_resolver.rb', line 4 def handlers @handlers end |
#payload ⇒ Object (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 |