Class: Odin::Types::OdinReference

Inherits:
OdinValue
  • Object
show all
Defined in:
lib/odin/types/values.rb

Instance Attribute Summary collapse

Attributes inherited from OdinValue

#directives, #modifiers

Instance Method Summary collapse

Methods inherited from OdinValue

#array?, #binary?, #boolean?, #confidential?, #currency?, #date?, #deprecated?, #duration?, #integer?, #null?, #number?, #numeric?, #object?, #percent?, #reference?, #required?, #string?, #temporal?, #time?, #timestamp?, #verb?

Constructor Details

#initialize(path, **kwargs) ⇒ OdinReference

Returns a new instance of OdinReference.



429
430
431
432
433
# File 'lib/odin/types/values.rb', line 429

def initialize(path, **kwargs)
  super(**kwargs)
  @path = path.freeze
  freeze
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



427
428
429
# File 'lib/odin/types/values.rb', line 427

def path
  @path
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



438
439
440
# File 'lib/odin/types/values.rb', line 438

def ==(other)
  other.is_a?(OdinReference) && path == other.path
end

#hashObject



443
444
445
# File 'lib/odin/types/values.rb', line 443

def hash
  [ValueType::REFERENCE, path].hash
end

#to_sObject



447
448
449
# File 'lib/odin/types/values.rb', line 447

def to_s
  "@#{path}"
end

#typeObject



435
# File 'lib/odin/types/values.rb', line 435

def type; ValueType::REFERENCE; end

#valueObject



436
# File 'lib/odin/types/values.rb', line 436

def value; @path; end

#with_directives(dirs) ⇒ Object



455
456
457
# File 'lib/odin/types/values.rb', line 455

def with_directives(dirs)
  OdinReference.new(path, modifiers: modifiers, directives: dirs)
end

#with_modifiers(mods) ⇒ Object



451
452
453
# File 'lib/odin/types/values.rb', line 451

def with_modifiers(mods)
  OdinReference.new(path, modifiers: mods, directives: directives)
end