Class: JSONAPI::PathSegment::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/jsonapi/path_segment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_klass:, field_name:) ⇒ Field

Returns a new instance of Field.



58
59
60
61
# File 'lib/jsonapi/path_segment.rb', line 58

def initialize(resource_klass:, field_name:)
  @resource_klass = resource_klass
  @field_name = field_name
end

Instance Attribute Details

#field_nameObject (readonly)

Returns the value of attribute field_name.



56
57
58
# File 'lib/jsonapi/path_segment.rb', line 56

def field_name
  @field_name
end

#resource_klassObject (readonly)

Returns the value of attribute resource_klass.



56
57
58
# File 'lib/jsonapi/path_segment.rb', line 56

def resource_klass
  @resource_klass
end

Instance Method Details

#delegated_field_nameObject



67
68
69
# File 'lib/jsonapi/path_segment.rb', line 67

def delegated_field_name
  resource_klass._attribute_delegated_name(field_name)
end

#eql?(other) ⇒ Boolean

Returns:



63
64
65
# File 'lib/jsonapi/path_segment.rb', line 63

def eql?(other)
  other.is_a?(self.class) && field_name == other.field_name && resource_klass == other.resource_klass
end

#to_sObject



71
72
73
74
75
# File 'lib/jsonapi/path_segment.rb', line 71

def to_s
  # :nocov:
  "#{resource_klass._type}.#{field_name.to_s}"
  # :nocov:
end