Class: SafeOpenStruct

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/rcs-common/updater/dsl.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rcs-common/updater/dsl.rb', line 5

def method_missing(meth, *args)
  n = meth.to_s

  if n.end_with?("?")
    n = n[0..-2]
    return @table[n] || @table[n.to_sym]
  elsif !n.end_with?("=")
    raise(NoMethodError, "no `#{meth}' member set yet")
  end

  super
end