Class: Azeroth::Decorator::HashBuilder Private
- Inherits:
-
Object
- Object
- Azeroth::Decorator::HashBuilder
- Defined in:
- lib/azeroth/decorator/hash_builder.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class responsible for building the hash on Decorator#as_json calls
Instance Method Summary collapse
-
#as_json ⇒ Hash
private
Build hash as defined by decorator.
-
#initialize(decorator) ⇒ HashBuilder
constructor
private
A new instance of HashBuilder.
Constructor Details
#initialize(decorator) ⇒ HashBuilder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of HashBuilder.
14 15 16 |
# File 'lib/azeroth/decorator/hash_builder.rb', line 14 def initialize(decorator) @decorator = decorator end |
Instance Method Details
#as_json ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build hash as defined by decorator
The built of the hash keys is defined by decorator attributes and method calls to the same decorator that will then delgate, when needed, to its object
26 27 28 29 30 31 32 33 |
# File 'lib/azeroth/decorator/hash_builder.rb', line 26 def as_json attributes_map.inject({}) do |hash, (method, )| new_hash = KeyValueExtractor.new( decorator: decorator, attribute: method, options: ).as_json hash.merge!(new_hash) end end |