Class: IronBank::Collection

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/iron_bank/collection.rb

Overview

Collection class which allows records reloadable from the source

Instance Method Summary collapse

Constructor Details

#initialize(klass, conditions, records) ⇒ Collection

Returns a new instance of Collection.



18
19
20
21
22
# File 'lib/iron_bank/collection.rb', line 18

def initialize(klass, conditions, records)
  @klass = klass
  @conditions = conditions
  @records = records
end

Instance Method Details

#reloadObject

Update records from source



25
26
27
# File 'lib/iron_bank/collection.rb', line 25

def reload
  @records = @klass.where(@conditions)
end

#to_aObject

In case you need to access all array methods



30
31
32
# File 'lib/iron_bank/collection.rb', line 30

def to_a
  @records
end