Sha256: c33407743a0440a751c58a614e3d5bfdb4a363ed0d1eb67afe8b7450e86be968
Contents?: true
Size: 529 Bytes
Versions: 2
Compression:
Stored size: 529 Bytes
Contents
# o = DynamicClass.new name: 'a' # o.name -> 'a' # o.name = 'b' # o.name 'b' # o.name -> 'b' # o.name = nil # o.name -> nil # o.title -> raises error class DynamicClass def initialize data, &block @data = data @block = block if block end def method_missing m, arg=:_UNDEF key = m.to_s.sub('=','').to_sym unless @data.has_key?(key) raise ArgumentError.new('Key :%s not found in DynamicOptions' % key) end if arg == :_UNDEF @data[key] else @data[key] = arg end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lux-fw-0.2.3 | ./lib/common/dynamic_class.rb |
lux-fw-0.2.1 | ./lib/common/dynamic_class.rb |