Method: Orator::OpenStruct#method_missing
- Defined in:
- lib/orator/open_struct.rb
#method_missing(method, *args) ⇒ Object
This handles the magic of this class. If the method doesn’t end in ‘=`, it checks to see if the element exists in the table; if not, it calls `super`. Otherwise, it sets the value and carries on. It ignores blocks given to it. If too many arguments are passed, it calls `super`.
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/orator/open_struct.rb', line 50 def method_missing(method, *args) method = method.to_s raise ArgumentError if args.length > 1 if method =~ /\=\z/ self[method[0..-2]] = args[0] else raise ArgumentError if args.length > 0 super unless @table.key?(method) self[method] end end |