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.
24 25 26 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 24 def context @context end |
#includes ⇒ Object (readonly)
Returns the value of attribute includes.
24 25 26 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 24 def includes @includes end |
#jat_class ⇒ Object (readonly)
Returns the value of attribute jat_class.
24 25 26 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 24 def jat_class @jat_class end |
#map ⇒ Object (readonly)
Returns the value of attribute map.
24 25 26 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 24 def map @map end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
24 25 26 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 24 def object @object end |
#type_map ⇒ Object (readonly)
Returns the value of attribute type_map.
24 25 26 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 24 def type_map @type_map end |
Instance Method Details
#initialize(object, context, map, includes) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 26 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
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 35 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
51 52 53 |
# File 'lib/jat/plugins/json_api/lib/response_piece.rb', line 51 def uid {type: type, id: id} end |