Module: V8::Access::Indices

Included in:
V8::Access
Defined in:
lib/v8/access/indices.rb

Instance Method Summary collapse

Instance Method Details

#idelete(obj, index, &dontintercept) ⇒ Object



35
36
37
# File 'lib/v8/access/indices.rb', line 35

def idelete(obj, index, &dontintercept)
  yield
end

#iget(obj, index, &dontintercept) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/v8/access/indices.rb', line 8

def iget(obj, index, &dontintercept)
  if obj.respond_to?(:[])
    obj.send(:[], index, &dontintercept)
  else
    yield
  end
end

#indices(obj) ⇒ Object



4
5
6
# File 'lib/v8/access/indices.rb', line 4

def indices(obj)
  obj.respond_to?(:length) ? (0..obj.length).to_a : []
end

#iquery(obj, index, attributes, &dontintercept) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/v8/access/indices.rb', line 24

def iquery(obj, index, attributes, &dontintercept)
  if obj.respond_to?(:[])
    attributes.dont_delete
    unless obj.respond_to?(:[]=)
      attributes.read_only
    end
  else
    yield
  end
end

#iset(obj, index, value, &dontintercept) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/v8/access/indices.rb', line 16

def iset(obj, index, value, &dontintercept)
  if obj.respond_to?(:[]=)
    obj.send(:[]=, index, value, &dontintercept)
  else
    yield
  end
end