Module: Jat::Plugins::SimpleApi::Response::InstanceMethods
- Included in:
- Jat::Plugins::SimpleApi::Response
- Defined in:
- lib/jat/plugins/simple_api/lib/response.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#jat_class ⇒ Object
readonly
Returns the value of attribute jat_class.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
15 16 17 |
# File 'lib/jat/plugins/simple_api/lib/response.rb', line 15 def context @context end |
#jat_class ⇒ Object (readonly)
Returns the value of attribute jat_class.
15 16 17 |
# File 'lib/jat/plugins/simple_api/lib/response.rb', line 15 def jat_class @jat_class end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
15 16 17 |
# File 'lib/jat/plugins/simple_api/lib/response.rb', line 15 def object @object end |
Instance Method Details
#initialize(object, context) ⇒ Object
17 18 19 20 21 |
# File 'lib/jat/plugins/simple_api/lib/response.rb', line 17 def initialize(object, context) @object = object @context = context @jat_class = self.class.jat_class end |
#to_h ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/jat/plugins/simple_api/lib/response.rb', line 23 def to_h # Add main response is_many = many? root = root_key(is_many) response = is_many ? many(object) : one(object) response = {root => response} if root response ||= {} (response, root) response end |