Module: Jat::Plugins::JsonApi::ResponsePiece::InstanceMethods
- Included in:
- Jat::Plugins::JsonApi::ResponsePiece
- Defined in:
- lib/jat/plugins/json_api/lib/response_piece.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#includes ⇒ Object
readonly
Returns the value of attribute includes.
-
#jat_class ⇒ Object
readonly
Returns the value of attribute jat_class.
-
#map ⇒ Object
readonly
Returns the value of attribute map.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#type_map ⇒ Object
readonly
Returns the value of attribute type_map.
Instance Method Summary collapse
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
14 15 16 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 14 def context @context end |
#includes ⇒ Object (readonly)
Returns the value of attribute includes.
14 15 16 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 14 def includes @includes end |
#jat_class ⇒ Object (readonly)
Returns the value of attribute jat_class.
14 15 16 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 14 def jat_class @jat_class end |
#map ⇒ Object (readonly)
Returns the value of attribute map.
14 15 16 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 14 def map @map end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
14 15 16 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 14 def object @object end |
#type_map ⇒ Object (readonly)
Returns the value of attribute type_map.
14 15 16 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 14 def type_map @type_map end |
Instance Method Details
#initialize(object, context, map, includes) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 16 def initialize(object, context, map, includes) @jat_class = self.class.jat_class @object = object @context = context @map = map @type_map = map.fetch(jat_class.get_type) @includes = includes end |
#to_h ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 25 def to_h return unless object attributes = get_attributes relationships = get_relationships links = get_links = result = uid result[:attributes] = attributes if attributes result[:relationships] = relationships if relationships result[:links] = links if links.any? result[:meta] = if .any? result end |
#uid ⇒ Object
41 42 43 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 41 def uid {type: type, id: id} end |