Class: ArrayModel

Inherits:
ReactiveArray show all
Includes:
ModelWrapper
Defined in:
lib/volt/models/array_model.rb

Direct Known Subclasses

ParamsArray, StoreArray

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ModelWrapper

#wrap_value, #wrap_values

Methods inherited from ReactiveArray

#==, #[]=, #delete_at, #insert, #inspect, #method_missing, #split_scope, #trigger_for_index!, #trigger_on_direct_listeners!, #trigger_size_change!

Methods included from ObjectTracking

#__setup_tracking

Methods included from ReactiveTags

included, #reactive_method_tag

Constructor Details

#initialize(array = [], parent = nil, path = nil) ⇒ ArrayModel

Returns a new instance of ArrayModel.



8
9
10
11
12
13
14
15
# File 'lib/volt/models/array_model.rb', line 8

def initialize(array=[], parent=nil, path=nil)
  @parent = parent
  @path = path || []
  
  array = wrap_values(array)
  
  super(array)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ReactiveArray

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



6
7
8
# File 'lib/volt/models/array_model.rb', line 6

def parent
  @parent
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/volt/models/array_model.rb', line 6

def path
  @path
end

Instance Method Details

#+(*args) ⇒ Object

Make sure it gets wrapped



35
36
37
38
# File 'lib/volt/models/array_model.rb', line 35

def +(*args)
  args = wrap_values(args)
  super(*args)
end

#<<(*args) ⇒ Object

Make sure it gets wrapped



22
23
24
25
26
# File 'lib/volt/models/array_model.rb', line 22

def <<(*args)
  args = wrap_values(args)
  
  super(*args)
end

#attributesObject



17
18
19
# File 'lib/volt/models/array_model.rb', line 17

def attributes
  self
end

#inject(*args) ⇒ Object

Make sure it gets wrapped



29
30
31
32
# File 'lib/volt/models/array_model.rb', line 29

def inject(*args)
  args = wrap_values(args)
  super(*args)
end

#new_array_model(*args) ⇒ Object



44
45
46
# File 'lib/volt/models/array_model.rb', line 44

def new_array_model(*args)
  ArrayModel.new(*args)
end

#new_model(*args) ⇒ Object



40
41
42
# File 'lib/volt/models/array_model.rb', line 40

def new_model(*args)
  Model.new(*args)
end