Class: IronBank::Collection
- Inherits:
-
Object
- Object
- IronBank::Collection
- 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
-
#initialize(klass, conditions, records) ⇒ Collection
constructor
A new instance of Collection.
-
#reload ⇒ Object
Update records from source.
-
#to_a ⇒ Object
In case you need to access all array methods.
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
#reload ⇒ Object
Update records from source
25 26 27 |
# File 'lib/iron_bank/collection.rb', line 25 def reload @records = @klass.where(@conditions) end |
#to_a ⇒ Object
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 |