Class: CRStruct::Open
- Inherits:
-
Object
- Object
- CRStruct::Open
- Defined in:
- lib/crstruct.rb
Direct Known Subclasses
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(key, *args, &blk) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/crstruct.rb', line 4 def method_missing(key, *args, &blk) super unless blk.nil? and key[-1]=='=' and args.length==1 k,v = key[0..-2].to_sym,args[0] raise FrozenError, "can't modify CRStruct method: :#{k}" if respond_to? k define_singleton_method(k){v} end |