Class: IssueBeaver::Shared::ModelCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/issue_beaver/shared/model_collection.rb

Instance Method Summary collapse

Constructor Details

#initialize(model, array) ⇒ ModelCollection

Returns a new instance of ModelCollection.



5
6
7
8
# File 'lib/issue_beaver/shared/model_collection.rb', line 5

def initialize(model, array)
  @model = model
  @array = array
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



16
17
18
19
20
21
22
23
# File 'lib/issue_beaver/shared/model_collection.rb', line 16

def method_missing(name, *args, &block)
  if @model.respond_to?(name)
    target = @model
  else
    target = @array
  end
  target.send(name, *args, &block)
end

Instance Method Details

#dupObject



11
12
13
# File 'lib/issue_beaver/shared/model_collection.rb', line 11

def dup
  self.class.new(@model, @array.dup)
end