Class: GenesisRuby::Utils::Options::Base

Inherits:
Hash
  • Object
show all
Defined in:
lib/genesis_ruby/utils/options/base.rb

Overview

Simple key value hash object Usage: ConfigurableOptions.<name>=, ConfigurableOptions.<name>

Direct Known Subclasses

ApiConfig, NetworkAdapterConfig, Reminder

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

Dynamic accessors for the hash



19
20
21
22
23
24
25
26
# File 'lib/genesis_ruby/utils/options/base.rb', line 19

def method_missing(name, *args)
  name_string = name.to_s
  if name_string.chomp!('=')
    self[name_string] = args.first
  else
    self[name_string]
  end
end

Instance Method Details

#[](key) ⇒ Object



14
15
16
# File 'lib/genesis_ruby/utils/options/base.rb', line 14

def [](key)
  super(key.to_sym)
end

#[]=(key, value) ⇒ Object



10
11
12
# File 'lib/genesis_ruby/utils/options/base.rb', line 10

def []=(key, value)
  super(key.to_sym, value)
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Define ConfigurableOptions.method(“<method>”) call If we dont have defined hash key we will raise exception

Returns:

  • (Boolean)


30
31
32
# File 'lib/genesis_ruby/utils/options/base.rb', line 30

def respond_to_missing?(name, include_private = false)
  method_missing(name) || super
end