Class: Respo::Response
- Inherits:
-
Object
- Object
- Respo::Response
- Extended by:
- Forwardable
- Includes:
- Helpers
- Defined in:
- lib/respo/response.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(record, **args) ⇒ Response
constructor
A new instance of Response.
- #serializer ⇒ Object
Methods included from Helpers
#action_name, #camelize, pluralize, singularize
Constructor Details
#initialize(record, **args) ⇒ Response
20 21 22 23 24 25 26 27 |
# File 'lib/respo/response.rb', line 20 def initialize(record, **args) @record = record # NOTE: dynamically define instance variables args.each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#record ⇒ Object (readonly)
Returns the value of attribute record.
10 11 12 |
# File 'lib/respo/response.rb', line 10 def record @record end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
10 11 12 |
# File 'lib/respo/response.rb', line 10 def root @root end |
#view ⇒ Object (readonly)
Returns the value of attribute view.
10 11 12 |
# File 'lib/respo/response.rb', line 10 def view @view end |
Class Method Details
.call(record, **args) ⇒ Object
15 16 17 |
# File 'lib/respo/response.rb', line 15 def call(record, **args) new(record, **args).call end |
Instance Method Details
#serializer ⇒ Object
29 30 31 32 |
# File 'lib/respo/response.rb', line 29 def serializer name = camelize(Respo.configuration.serializer.to_s) @serializer ||= Object.const_get("Respo::Serializers::#{name}") end |