Class: Odin::Types::OdinDirective

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value = nil) ⇒ OdinDirective

Returns a new instance of OdinDirective.



8
9
10
11
12
# File 'lib/odin/types/directive.rb', line 8

def initialize(name, value = nil)
  @name = -name.to_s
  @value = value&.freeze
  freeze
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/odin/types/directive.rb', line 6

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/odin/types/directive.rb', line 6

def value
  @value
end

Instance Method Details

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



14
15
16
# File 'lib/odin/types/directive.rb', line 14

def ==(other)
  other.is_a?(OdinDirective) && name == other.name && value == other.value
end

#hashObject



19
20
21
# File 'lib/odin/types/directive.rb', line 19

def hash
  [name, value].hash
end

#to_sObject



23
24
25
# File 'lib/odin/types/directive.rb', line 23

def to_s
  value ? "#{name}(#{value})" : name
end