Class: Dao::Conducer::Collection

Inherits:
Array
  • Object
show all
Defined in:
lib/dao/conducer/collection.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Array

#as_dao, #to_dao

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



43
44
45
46
# File 'lib/dao/conducer/collection.rb', line 43

def method_missing(method, *args, &block)
  return(models.send(method, *args, &block)) if models.respond_to?(method)
  super
end

Class Method Details

.load(*args, &block) ⇒ Object



26
27
28
# File 'lib/dao/conducer/collection.rb', line 26

def load(*args, &block)
  new.tap{|collection| collection.load(*args, &block)}
end

Instance Method Details

#conducer_classObject



33
34
35
# File 'lib/dao/conducer/collection.rb', line 33

def conducer_class
  self.class.conducer_class
end

#load(models, *args, &block) ⇒ Object



37
38
39
40
41
# File 'lib/dao/conducer/collection.rb', line 37

def load(models, *args, &block)
  block ||= proc{|model| conducer_class.new(model, *args) }
  (self.models = models).each{|model| self << block.call(model, *args)}
  self
end