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.



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/atatus/config/options.rb', line 126

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.



145
146
147
# File 'lib/atatus/config/options.rb', line 145

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.



120
121
122
123
124
# File 'lib/atatus/config/options.rb', line 120

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.



150
151
152
153
154
155
# File 'lib/atatus/config/options.rb', line 150

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