Class: SimpleJsonapi::Node::Resource::Base
- Defined in:
- lib/simple_jsonapi/node/resource/base.rb
Overview
Represents a single resource object or resource linkage object.
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Attributes inherited from Base
#extras, #fields_spec, #include_spec, #root_node, #serializer, #serializer_inferrer, #sort_spec
Instance Method Summary collapse
-
#initialize(resource:, **options) ⇒ Base
constructor
A new instance of Base.
- #resource_id ⇒ Object
- #resource_type ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(resource:, **options) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 11 |
# File 'lib/simple_jsonapi/node/resource/base.rb', line 6 def initialize(resource:, **) super() @resource = resource @serializer = serializer_inferrer.infer(resource).new end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
4 5 6 |
# File 'lib/simple_jsonapi/node/resource/base.rb', line 4 def resource @resource end |
Instance Method Details
#resource_id ⇒ Object
13 14 15 |
# File 'lib/simple_jsonapi/node/resource/base.rb', line 13 def resource_id @resource_id ||= evaluate(serializer.id_definition, resource).to_s end |
#resource_type ⇒ Object
17 18 19 |
# File 'lib/simple_jsonapi/node/resource/base.rb', line 17 def resource_type @resource_type ||= evaluate(serializer.type_definition, resource).to_s end |