Class: JSONAPI::PathSegment::Relationship
- Inherits:
-
Object
- Object
- JSONAPI::PathSegment::Relationship
- Defined in:
- lib/jsonapi/path_segment.rb
Instance Attribute Summary collapse
-
#relationship ⇒ Object
readonly
Returns the value of attribute relationship.
-
#resource_klass ⇒ Object
readonly
Returns the value of attribute resource_klass.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(relationship:, resource_klass: nil) ⇒ Relationship
constructor
A new instance of Relationship.
- #path_specified_resource_klass? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(relationship:, resource_klass: nil) ⇒ Relationship
Returns a new instance of Relationship.
27 28 29 30 |
# File 'lib/jsonapi/path_segment.rb', line 27 def initialize(relationship:, resource_klass: nil) @relationship = relationship @resource_klass = resource_klass end |
Instance Attribute Details
#relationship ⇒ Object (readonly)
Returns the value of attribute relationship.
25 26 27 |
# File 'lib/jsonapi/path_segment.rb', line 25 def relationship @relationship end |
#resource_klass ⇒ Object (readonly)
Returns the value of attribute resource_klass.
25 26 27 |
# File 'lib/jsonapi/path_segment.rb', line 25 def resource_klass @resource_klass end |
Instance Method Details
#eql?(other) ⇒ Boolean
32 33 34 |
# File 'lib/jsonapi/path_segment.rb', line 32 def eql?(other) other.is_a?(JSONAPI::PathSegment::Relationship) && relationship == other.relationship && resource_klass == other.resource_klass end |
#hash ⇒ Object
36 37 38 |
# File 'lib/jsonapi/path_segment.rb', line 36 def hash [relationship, resource_klass].hash end |
#path_specified_resource_klass? ⇒ Boolean
48 49 50 |
# File 'lib/jsonapi/path_segment.rb', line 48 def path_specified_resource_klass? !@resource_klass.nil? end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/jsonapi/path_segment.rb', line 40 def to_s @resource_klass ? "#{relationship.parent_resource_klass._type}.#{relationship.name}##{resource_klass._type}" : "#{resource_klass._type}.#{relationship.name}" end |