Class: ThinModels::LazyArray::Memoized::Mapped
Overview
For when you want to map to a ThinModels::LazyArray which memoizes the results of the map
Instance Method Summary
collapse
#[], #each, #inspect, #to_a
#each, #inspect, #length
#[], #each, #empty?, #first, #inspect, #join, #last, #length, #map, #size, #to_json
Constructor Details
#initialize(underlying, &block) ⇒ Mapped
208
209
210
|
# File 'lib/thin_models/lazy_array.rb', line 208
def initialize(underlying, &block)
@underlying = underlying; @block = block
end
|
Instance Method Details
#_each ⇒ Object
212
213
214
|
# File 'lib/thin_models/lazy_array.rb', line 212
def _each
@underlying.each {|x| yield @block.call(x)}
end
|
#_length ⇒ Object
216
217
218
|
# File 'lib/thin_models/lazy_array.rb', line 216
def _length
@underlying.length
end
|
#slice_from_start_and_length(start, length) ⇒ Object
220
221
222
|
# File 'lib/thin_models/lazy_array.rb', line 220
def slice_from_start_and_length(start, length)
@underlying.slice_from_start_and_length(start, length).map(&@block)
end
|