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.



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

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.



54
55
56
# File 'lib/jsonapi/path_segment.rb', line 54

def field_name
  @field_name
end

#resource_klassObject (readonly)

Returns the value of attribute resource_klass.



54
55
56
# File 'lib/jsonapi/path_segment.rb', line 54

def resource_klass
  @resource_klass
end

Instance Method Details

#delegated_field_nameObject



65
66
67
# File 'lib/jsonapi/path_segment.rb', line 65

def delegated_field_name
  resource_klass._attribute_delegated_name(field_name)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/jsonapi/path_segment.rb', line 61

def eql?(other)
  other.is_a?(JSONAPI::PathSegment::Field) && field_name == other.field_name && resource_klass == other.resource_klass
end

#to_sObject



69
70
71
72
73
# File 'lib/jsonapi/path_segment.rb', line 69

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