Class: ActiveRecordSamplooper::ArrayLooper
- Inherits:
-
Object
- Object
- ActiveRecordSamplooper::ArrayLooper
- Defined in:
- lib/active_record_samplooper.rb
Instance Attribute Summary collapse
-
#array ⇒ Object
Returns the value of attribute array.
Class Method Summary collapse
Instance Method Summary collapse
- #find(id) ⇒ Object
-
#initialize(array) ⇒ ArrayLooper
constructor
A new instance of ArrayLooper.
- #pluck ⇒ Object
Constructor Details
#initialize(array) ⇒ ArrayLooper
Returns a new instance of ArrayLooper.
24 25 26 |
# File 'lib/active_record_samplooper.rb', line 24 def initialize(array) self.array = array.dup end |
Instance Attribute Details
#array ⇒ Object
Returns the value of attribute array.
14 15 16 |
# File 'lib/active_record_samplooper.rb', line 14 def array @array end |
Class Method Details
.call(*args) ⇒ Object
18 19 20 |
# File 'lib/active_record_samplooper.rb', line 18 def call(*args) new(*args) end |
Instance Method Details
#find(id) ⇒ Object
29 30 31 32 |
# File 'lib/active_record_samplooper.rb', line 29 def find(id) raise ActiveRecord::RecordNotFound unless id array[id - 1] || raise(Gone, id) end |
#pluck ⇒ Object
35 36 37 |
# File 'lib/active_record_samplooper.rb', line 35 def pluck(*) (1..array.size).to_a end |