Class: Metaractor::Parameters::Parameter

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/metaractor/parameters.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, **options) ⇒ Parameter

Returns a new instance of Parameter.



26
27
28
29
# File 'lib/metaractor/parameters.rb', line 26

def initialize(name, **options)
  @name = name.to_sym
  @options = options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



24
25
26
# File 'lib/metaractor/parameters.rb', line 24

def name
  @name
end

Instance Method Details

#<=>(other) ⇒ Object



31
32
33
34
35
# File 'lib/metaractor/parameters.rb', line 31

def <=>(other)
  return nil unless other.instance_of? self.class
  return nil if name == other.name && options != other.options
  name.to_s <=> other.name.to_s
end

#[](key) ⇒ Object



37
38
39
# File 'lib/metaractor/parameters.rb', line 37

def [](key)
  @options[key]
end

#dig(name, *names) ⇒ Object



45
46
47
# File 'lib/metaractor/parameters.rb', line 45

def dig(name, *names)
  @options.dig(name, *names)
end

#has_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/metaractor/parameters.rb', line 41

def has_key?(key)
  @options.has_key?(key)
end

#merge!(**options) ⇒ Object



49
50
51
# File 'lib/metaractor/parameters.rb', line 49

def merge!(**options)
  @options.merge!(**options)
end

#to_sObject



53
54
55
# File 'lib/metaractor/parameters.rb', line 53

def to_s
  name.to_s
end

#to_symObject



57
58
59
# File 'lib/metaractor/parameters.rb', line 57

def to_sym
  name
end