Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/aqua/object/initializers.rb

Direct Known Subclasses

Aqua::Store::CouchDB::ResultSet

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.aqua_init(init, opts = Aqua::Translator::Opts.new) ⇒ Object



174
175
176
177
178
179
180
# File 'lib/aqua/object/initializers.rb', line 174

def self.aqua_init( init, opts=Aqua::Translator::Opts.new ) 
  # todo: make opts opts.path follow the path through the base object
  array_init = init.map{ |obj| Aqua::Translator.unpack_object(obj, opts) } 
  # new is neccessary to make sure array derivatives maintain their class
  # without having to override aqua_init! 
  self == Array ? array_init : new( array_init ) 
end

Instance Method Details

#to_aqua_init(path = '') ⇒ Object



164
165
166
167
168
169
170
171
172
# File 'lib/aqua/object/initializers.rb', line 164

def to_aqua_init( path = '' )
  rat = Aqua::Translator::Rat.new([])
  self.each_with_index do |obj, index|
    local_path = path + "[#{index}]" 
    obj_rat = Aqua::Translator.pack_object( obj, local_path )
    rat.eat( obj_rat )  
  end
  rat   
end