Module: Jat::Plugins::JsonApi::Response::InstanceMethods
- Included in:
- Jat::Plugins::JsonApi::Response
- Defined in:
- lib/jat/plugins/json_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.
25 26 27 |
# File 'lib/jat/plugins/json_api/lib/response.rb', line 25 def context @context end |
#jat_class ⇒ Object (readonly)
Returns the value of attribute jat_class.
25 26 27 |
# File 'lib/jat/plugins/json_api/lib/response.rb', line 25 def jat_class @jat_class end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
25 26 27 |
# File 'lib/jat/plugins/json_api/lib/response.rb', line 25 def object @object end |
Instance Method Details
#initialize(object, context) ⇒ Object
27 28 29 30 31 |
# File 'lib/jat/plugins/json_api/lib/response.rb', line 27 def initialize(object, context) @object = object @context = context @jat_class = self.class.jat_class end |
#to_h ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/jat/plugins/json_api/lib/response.rb', line 33 def to_h data, includes = data_with_includes = links = document_links jsonapi = jsonapi_data result = {} result[:links] = links if links.any? result[:data] = data if data result[:included] = includes.values if includes.any? result[:meta] = if .any? result[:jsonapi] = jsonapi if jsonapi.any? result end |