Class: JSObject::JSHash
- Inherits:
-
Hash
- Object
- Hash
- JSObject::JSHash
- Defined in:
- lib/dnode/jsobject.rb
Constant Summary collapse
- @@names =
[]
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.create(hash) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dnode/jsobject.rb', line 9 def self.create hash @@names.each { |name| remove_method(name) } @@names = hash.keys hash.each do |name,value| define_method(name) do |*args,&block| if value.is_a? Proc then if block.nil? then value.call(*args) else value.call(*args) { |*iargs| block.call(*iargs) } end else value end end end self.new.update(hash) end |
Instance Method Details
#[](key) ⇒ Object
5 |
# File 'lib/dnode/jsobject.rb', line 5 def [] key; super key.to_s; end |
#[]=(key, value) ⇒ Object
6 |
# File 'lib/dnode/jsobject.rb', line 6 def []= key, value; super key.to_s, value; end |