Class: StrokeDB::ArraySlotValue

Inherits:
LazyMappingArray show all
Defined in:
lib/strokedb/document/slot.rb

Constant Summary

Constants inherited from Array

Array::SDATPTAGS

Instance Method Summary collapse

Methods inherited from LazyMappingArray

#-, #==, #[], #_at, #_each, #_find, #_include?, #_index, #_map, #_pop, #_push, #_shift, #_square_brackets, #_square_brackets_set, #_substract, #_unshift, #_zip, #at, #class, #each, #find, #first, #index, #initialize, #last, #map, #map_with, #pop, #shift, #to_a, #unmap_with, #zip

Methods inherited from Array

#stroke_diff, #stroke_merge, #stroke_patch, #to_raw

Constructor Details

This class inherits a constructor from StrokeDB::LazyMappingArray

Instance Method Details

#<<(*args) ⇒ Object



30
31
32
33
# File 'lib/strokedb/document/slot.rb', line 30

def <<(*args)
  super(*args)
  @modification_callback.call if @modification_callback
end

#[]=(*args) ⇒ Object



22
23
24
25
# File 'lib/strokedb/document/slot.rb', line 22

def []=(*args)
  super(*args)
  @modification_callback.call if @modification_callback
end

#include?(v) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
45
46
47
48
# File 'lib/strokedb/document/slot.rb', line 39

def include?(v) 
  case v
  when VersionedDocument
    super(v)
  when Document
    v.versions.all.find{|d| super(d)} # FIXME: versions.all could be pretty slow
  else
    super(v)
  end
end

#push(*args) ⇒ Object



26
27
28
29
# File 'lib/strokedb/document/slot.rb', line 26

def push(*args)
  super(*args)
  @modification_callback.call if @modification_callback
end

#unshift(*args) ⇒ Object



34
35
36
37
# File 'lib/strokedb/document/slot.rb', line 34

def unshift(*args)
  super(*args)
  @modification_callback.call if @modification_callback
end

#with_modification_callback(&block) ⇒ Object



18
19
20
21
# File 'lib/strokedb/document/slot.rb', line 18

def with_modification_callback(&block)
  @modification_callback = block
  self
end