Class: ArrayModel
- Inherits:
-
ReactiveArray
- Object
- ReactiveArray
- ArrayModel
- Includes:
- ModelHelpers, ModelWrapper
- Defined in:
- lib/volt/models/array_model.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#persistor ⇒ Object
readonly
Returns the value of attribute persistor.
Instance Method Summary collapse
-
#+(*args) ⇒ Object
Make sure it gets wrapped.
-
#<<(*args) ⇒ Object
Make sure it gets wrapped.
- #attributes ⇒ Object
-
#initialize(array = [], options = {}) ⇒ ArrayModel
constructor
A new instance of ArrayModel.
-
#inject(*args) ⇒ Object
Make sure it gets wrapped.
- #new_array_model(*args) ⇒ Object
- #new_model(*args) ⇒ Object
-
#to_a ⇒ Object
Convert the model to an array all of the way down.
Methods included from ModelHelpers
Methods included from ModelWrapper
Methods inherited from ReactiveArray
#==, #[]=, #delete, #delete_at, #each, #insert, #inspect, #method_missing, #split_scope, #trigger_for_index!, #trigger_on_direct_listeners!, #trigger_size_change!
Methods included from ObjectTracking
Methods included from ReactiveTags
included, #reactive_method_tag
Constructor Details
#initialize(array = [], options = {}) ⇒ ArrayModel
Returns a new instance of ArrayModel.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/volt/models/array_model.rb', line 10 def initialize(array=[], ={}) @options = @parent = [:parent] @path = [:path] || [] @persistor = setup_persistor([:persistor]) array = wrap_values(array) super(array) @persistor.loaded if @persistor end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ReactiveArray
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/volt/models/array_model.rb', line 8 def @options end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
8 9 10 |
# File 'lib/volt/models/array_model.rb', line 8 def parent @parent end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/volt/models/array_model.rb', line 8 def path @path end |
#persistor ⇒ Object (readonly)
Returns the value of attribute persistor.
8 9 10 |
# File 'lib/volt/models/array_model.rb', line 8 def persistor @persistor end |
Instance Method Details
#+(*args) ⇒ Object
Make sure it gets wrapped
43 44 45 46 |
# File 'lib/volt/models/array_model.rb', line 43 def +(*args) args = wrap_values(args) super(*args) end |
#<<(*args) ⇒ Object
Make sure it gets wrapped
28 29 30 31 32 33 34 |
# File 'lib/volt/models/array_model.rb', line 28 def <<(*args) args = wrap_values(args) super(*args) @persistor.added(args[0], @array.size-1) if @persistor end |
#attributes ⇒ Object
23 24 25 |
# File 'lib/volt/models/array_model.rb', line 23 def attributes self end |
#inject(*args) ⇒ Object
Make sure it gets wrapped
37 38 39 40 |
# File 'lib/volt/models/array_model.rb', line 37 def inject(*args) args = wrap_values(args) super(*args) end |
#new_array_model(*args) ⇒ Object
52 53 54 |
# File 'lib/volt/models/array_model.rb', line 52 def new_array_model(*args) ArrayModel.new(*args) end |
#new_model(*args) ⇒ Object
48 49 50 |
# File 'lib/volt/models/array_model.rb', line 48 def new_model(*args) Model.new(*args) end |
#to_a ⇒ Object
Convert the model to an array all of the way down
57 58 59 60 61 62 63 64 |
# File 'lib/volt/models/array_model.rb', line 57 def to_a array = [] attributes.each do |value| array << deep_unwrap(value) end return array end |