class V8::Access

Public Instance Methods

get(obj, name) { || ... } click to toggle source
# File lib/v8/access.rb, line 4
def get(obj, name, &dontintercept)
  methods = accessible_methods(obj)
  if methods.include?(name)
    method = obj.method(name)
    method.arity == 0 ? method.call : method.unbind
  elsif obj.respond_to?(:[])
    obj.send(:[], name, &dontintercept)
  else
    yield
  end
end
iget(obj, index) { || ... } click to toggle source
# File lib/v8/access.rb, line 16
def iget(obj, index, &dontintercept)
  if obj.respond_to?(:[])
    obj.send(:[], index, &dontintercept)
  else
    yield
  end
end
indices(obj) { || ... } click to toggle source
# File lib/v8/access.rb, line 70
def indices(obj)
  obj.respond_to?(:length) ? (0..obj.length).to_a : yield
end
iquery(obj, index, attributes) { || ... } click to toggle source
# File lib/v8/access.rb, line 55
def iquery(obj, index, attributes)
  if obj.respond_to?(:[])
    attributes.dont_delete
    unless obj.respond_to?(:[]=)
      attributes.read_only
    end
  else
    yield
  end
end
iset(obj, index, value) { || ... } click to toggle source
# File lib/v8/access.rb, line 36
def iset(obj, index, value, &dontintercept)
  if obj.respond_to?(:[]=)
    obj.send(:[]=, index, value, &dontintercept)
  else
    yield
  end
end
names(obj) click to toggle source
# File lib/v8/access.rb, line 66
def names(obj)
  accessible_methods(obj)
end
query(obj, name, attributes) { || ... } click to toggle source
# File lib/v8/access.rb, line 44
def query(obj, name, attributes)
  if obj.respond_to?(name)
    attributes.dont_delete
    unless obj.respond_to?(name + "=")
      attributes.read_only
    end
  else
    yield
  end
end
set(obj, name, value) { || ... } click to toggle source
# File lib/v8/access.rb, line 24
def set(obj, name, value, &dontintercept)
  setter = name + "="
  methods = accessible_methods(obj, true)
  if methods.include?(setter)
    obj.send(setter, value)
  elsif obj.respond_to?(:[]=)
    obj.send(:[]=, name, value, &dontintercept)
  else
    yield
  end
end