Skip to content

Commit

Permalink
Add basic inspect and exposing Ruby functions to js
Browse files Browse the repository at this point in the history
  • Loading branch information
wycats committed Aug 25, 2011
1 parent 475e2eb commit fd8661e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/sparta/runtime/object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ def self.with_constructor(constructor)
object
end

def function(name, block=name)
block = method(block) if block.is_a?(Symbol)

self[name] = Function.new(block)
end

def to_hash
Hash[*keys.zip(values).flatten]
end

def inspect
"#<#{object_id.to_s(16)} #{to_hash.inspect}>"
"#<#{spec_Class} #{object_id.to_s(16)} #{to_hash.inspect}>"
end

def spec_Get(name)
Expand Down Expand Up @@ -84,9 +90,14 @@ def self.empty_object
OBJECT_PROTOTYPE = Runtime::Object.new

class Window < Object
def initialize
function :p
end
end

class Function < Object
thunk_method :spec_Class, "Function"

def initialize(block)
@block = block
end
Expand Down

0 comments on commit fd8661e

Please sign in to comment.