Class: Easy::Configuration::Custom

Inherits:
Object
  • Object
show all
Defined in:
lib/easy/configuration/custom.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/easy/configuration/custom.rb', line 5

def method_missing(name, *args)
  name_string = name.to_s
  if name_string.chomp!("=")
    from_file[name_string] = args.first
  else
    bangs = name_string.chomp!("!")

    if bangs
      from_file[name_string].presence || raise(KeyError.new(":#{name_string} is blank"))
    else
      from_file[name_string]
    end
  end
end

Instance Method Details

#respond_to_missing?(name, include_private) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/easy/configuration/custom.rb', line 20

def respond_to_missing?(name, include_private)
  true
end