Class: Odin::Types::OdinModifiers

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

Constant Summary collapse

NONE =
new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(required: false, confidential: false, deprecated: false, attr: nil) ⇒ OdinModifiers

Returns a new instance of OdinModifiers.



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

def initialize(required: false, confidential: false, deprecated: false, attr: nil)
  @required = required
  @confidential = confidential
  @deprecated = deprecated
  @attr = attr
  freeze
end

Instance Attribute Details

#attrObject (readonly)

Returns the value of attribute attr.



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

def attr
  @attr
end

#confidentialObject (readonly)

Returns the value of attribute confidential.



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

def confidential
  @confidential
end

#deprecatedObject (readonly)

Returns the value of attribute deprecated.



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

def deprecated
  @deprecated
end

#requiredObject (readonly)

Returns the value of attribute required.



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

def required
  @required
end

Instance Method Details

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



22
23
24
25
26
27
28
# File 'lib/odin/types/modifiers.rb', line 22

def ==(other)
  other.is_a?(OdinModifiers) &&
    required == other.required &&
    confidential == other.confidential &&
    deprecated == other.deprecated &&
    self.attr == other.attr
end

#any?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/odin/types/modifiers.rb', line 18

def any?
  required || confidential || deprecated
end

#hashObject



31
32
33
# File 'lib/odin/types/modifiers.rb', line 31

def hash
  [required, confidential, deprecated, self.attr].hash
end

#to_sObject



35
36
37
38
39
40
41
42
# File 'lib/odin/types/modifiers.rb', line 35

def to_s
  parts = []
  parts << "required" if required
  parts << "confidential" if confidential
  parts << "deprecated" if deprecated
  parts << "attr=#{self.attr}" if self.attr
  parts.empty? ? "OdinModifiers(none)" : "OdinModifiers(#{parts.join(', ')})"
end