Class: V8::Access

Inherits:
Object
  • Object
show all
Defined in:
lib/horseman/browser/whiny_v8.rb

Instance Method Summary collapse

Instance Method Details

#get(obj, name, &dontintercept) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/horseman/browser/whiny_v8.rb', line 3

def get(obj, name, &dontintercept)
  puts "V8 get: #{obj.class.name} - #{name}"
  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, &dontintercept) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/horseman/browser/whiny_v8.rb', line 16

def iget(obj, index, &dontintercept)
  puts "V8 iget: #{obj.class.name} - #{name}"
  if obj.respond_to?(:[])
    obj.send(:[], index, &dontintercept)
  else
    yield
  end
end

#indices(obj) ⇒ Object



54
55
56
57
# File 'lib/horseman/browser/whiny_v8.rb', line 54

def indices(obj)
  puts "V8 indices: #{obj.class.name}"
  obj.respond_to?(:length) ? (0..obj.length).to_a : yield
end

#iquery(obj, index, attributes) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/horseman/browser/whiny_v8.rb', line 37

def iquery(obj, index, attributes)
  puts "V8 iquery: #{obj.class.name} - #{name}"
  if obj.respond_to?(:[])
    attributes.dont_delete
    unless obj.respond_to?(:[]=)
      attributes.read_only
    end
  else
    yield
  end
end

#names(obj) ⇒ Object



49
50
51
52
# File 'lib/horseman/browser/whiny_v8.rb', line 49

def names(obj)
  puts "V8 names: #{obj.class.name}"
  accessible_methods(obj)
end

#query(obj, name, attributes) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/horseman/browser/whiny_v8.rb', line 25

def query(obj, name, attributes)
  puts "V8 query: #{obj.class.name} - #{name}"
  if obj.respond_to?(name)
    attributes.dont_delete
    unless obj.respond_to?(name + "=")
      attributes.read_only
    end
  else
    yield
  end
end