Class: CloudBuilder::DSLOpenStruct
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- CloudBuilder::DSLOpenStruct
- Defined in:
- lib/cloud_builder/dslostruct.rb
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(mid, *args) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cloud_builder/dslostruct.rb', line 14 def method_missing(mid, *args) mname = mid.id2name len = args.length if mname.chomp!('=') if len != 1 raise ArgumentError, "wrong number of arguments (#{len} for 1)", caller(1) end modifiable[new_ostruct_member(mname)] = args[0] elsif len == 0 if @table.has_key? mid @table[mid] else raise NameError, "undefined property #{mid} for #{self}", caller(1) end else raise NoMethodError, "undefined method `#{mid}' for #{self}", caller(1) end end |