Class: Rico::Array
- Inherits:
-
Collection
- Object
- Collection
- Rico::Array
- Defined in:
- lib/rico/array.rb
Instance Attribute Summary
Attributes included from Object
Class Method Summary collapse
-
.resolve(robject) ⇒ Object
Resolve conflict between one or more RObject siblings.
Instance Method Summary collapse
-
#members ⇒ Object
Obtains the items in the array.
Methods inherited from Collection
Methods included from Object
#data, #exists?, #initialize, #mutate
Class Method Details
.resolve(robject) ⇒ Object
Resolve conflict between one or more RObject siblings
robjects - array of RObjects to merge
Returns a single RObject result or nil
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rico/array.rb', line 20 def self.resolve(robject) siblings = robject.siblings values = siblings.map {|r| Array(r.data["_values"]) } deletions = siblings.map {|r| Array(r.data["_deletes"]) }.flatten result = [] values.each do |v| result += (v - result) end result -= deletions obj = robject.dup obj.siblings = [obj.siblings.first] obj.data = { "_values" => result, "_deletes" => deletions } obj end |
Instance Method Details
#members ⇒ Object
Obtains the items in the array
Returns the data in the object as an array
9 10 11 12 13 |
# File 'lib/rico/array.rb', line 9 def members assert_type(::Array) do data["_values"] || [] end end |