Class: FullCircle::ResponseBuilder
- Inherits:
-
Object
- Object
- FullCircle::ResponseBuilder
- Defined in:
- lib/full_circle/response_builder.rb
Instance Attribute Summary collapse
-
#api_results ⇒ Object
readonly
Returns the value of attribute api_results.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#object_builder ⇒ Object
readonly
Returns the value of attribute object_builder.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(api_results, args = {}) ⇒ ResponseBuilder
constructor
Creates a new response builder api_results - collection of objects to be built into the response args metadata: hash of metadata object_builder: The object builder to use for building api objects.
Constructor Details
#initialize(api_results, args = {}) ⇒ ResponseBuilder
Creates a new response builder api_results - collection of objects to be built into the response args
metadata: hash of
object_builder: The object builder to use for building api objects
11 12 13 14 15 |
# File 'lib/full_circle/response_builder.rb', line 11 def initialize(api_results, args={}) @api_results = api_results = args.fetch(:metadata){{}} @object_builder = args.fetch(:object_builder){ObjectBuilder.new} end |
Instance Attribute Details
#api_results ⇒ Object (readonly)
Returns the value of attribute api_results.
4 5 6 |
# File 'lib/full_circle/response_builder.rb', line 4 def api_results @api_results end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
4 5 6 |
# File 'lib/full_circle/response_builder.rb', line 4 def end |
#object_builder ⇒ Object (readonly)
Returns the value of attribute object_builder.
4 5 6 |
# File 'lib/full_circle/response_builder.rb', line 4 def object_builder @object_builder end |
Instance Method Details
#build ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/full_circle/response_builder.rb', line 17 def build objects = api_results.map do |result| object_builder.from_api_hash(result) end Response.new(objects,) end |