Module: Atatus::Config::Options::InstanceMethods Private

Defined in:
lib/atatus/config/options.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/atatus/config/options.rb', line 117

def method_missing(name, *value)
  name_str = name.to_s

  if name_str.end_with?('=')
    key = name_str[0...-1].to_sym
    set(key, value.first)

  elsif name_str.end_with?('?')
    key = name_str[0...-1].to_sym
    options.key?(key) ? options[key].value : super

  elsif options.key?(name)
    options.fetch(name).value

  else
    super
  end
end

Instance Method Details

#[](key) ⇒ Object Also known as: get

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



136
137
138
# File 'lib/atatus/config/options.rb', line 136

def [](key)
  options[key]
end

#load_schemaObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



111
112
113
114
115
# File 'lib/atatus/config/options.rb', line 111

def load_schema
  Hash[self.class.schema.map do |key, args|
    [key, Option.new(key, **args)]
  end]
end

#set(key, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



141
142
143
144
145
146
# File 'lib/atatus/config/options.rb', line 141

def set(key, value)
  options.fetch(key.to_sym).set(value)
rescue KeyError
  warn format("Unknown option '%s'", key)
  nil
end