Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a0ff614d0e42
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3da7a07e9a3e
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Nov 30, 2013

  1. Copy the full SHA
    935a771 View commit details
  2. Fix Native::Object#respond_to?

    meh committed Nov 30, 2013
    Copy the full SHA
    3da7a07 View commit details
Showing with 15 additions and 4 deletions.
  1. +9 −2 opal/corelib/kernel.rb
  2. +6 −2 stdlib/native.rb
11 changes: 9 additions & 2 deletions opal/corelib/kernel.rb
Original file line number Diff line number Diff line change
@@ -488,10 +488,17 @@ def rand(max = undefined)
alias srand rand

def respond_to?(name, include_all = false)
return true if respond_to_missing?(name)

%x{
var body = self['$' + name];
return (!!body) && !body.rb_stub;
if (typeof(body) === "function" && !body.rb_stub) {
return true;
}
}

false
end

alias send __send__
@@ -574,7 +581,7 @@ def frozen?
@___frozen___ || false
end

def respond_to_missing? method_name
def respond_to_missing?(method_name)
false
end
end
8 changes: 6 additions & 2 deletions stdlib/native.rb
Original file line number Diff line number Diff line change
@@ -193,8 +193,12 @@ def []=(key, value)
end
end

def respond_to?(name, *)
`typeof(self["$" + name]) === "function" || #@native.hasOwnProperty(#{name})`
def respond_to?(name, include_all = false)
Kernel.instance_method(:respond_to?).bind(self).call(name, include_all)
end

def respond_to_missing?(name)
`#@native.hasOwnProperty(#{name})`
end

def method_missing(mid, *args, &block)