Class: SimpleJsonapi::Node::Document::Singular
- Defined in:
- lib/simple_jsonapi/node/document/singular.rb
Overview
Represents a JSONAPI document whose primary data is a single resource.
Instance Attribute Summary collapse
- #resource ⇒ Object readonly
Attributes inherited from Base
#extras, #fields_spec, #include_spec, #root_node, #serializer, #serializer_inferrer, #sort_spec
Instance Method Summary collapse
-
#initialize(resource:, **options) ⇒ Singular
constructor
A new instance of Singular.
Methods inherited from Base
#append_included_resource, #as_jsonapi, #included_resource?
Methods inherited from Base
Constructor Details
#initialize(resource:, **options) ⇒ Singular
Returns a new instance of Singular.
10 11 12 13 14 15 |
# File 'lib/simple_jsonapi/node/document/singular.rb', line 10 def initialize(resource:, **) super @resource = resource @data_node = build_child_node(SimpleJsonapi::Node::Data::Singular, resource: @resource) end |
Instance Attribute Details
#resource ⇒ Object (readonly)
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/simple_jsonapi/node/document/singular.rb', line 5 class Singular < Base attr_reader :resource # @param resource [Object] # @param options see {Node::Document::Base#initialize} for additional parameters def initialize(resource:, **) super @resource = resource @data_node = build_child_node(SimpleJsonapi::Node::Data::Singular, resource: @resource) end end |