Method: Sequel::Plugins::StaticCache::ClassMethods#map
- Defined in:
- lib/sequel/plugins/static_cache.rb
#map(column = nil, &block) ⇒ Object
Use the cache instead of a query to get the results.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/sequel/plugins/static_cache.rb', line 126 def map(column=nil, &block) if column raise(Error, "Cannot provide both column and block to map") if block if column.is_a?(Array) @all.map{|r| r.values.values_at(*column)} else @all.map{|r| r[column]} end elsif @static_cache_frozen @all.map(&block) elsif block @all.map{|o| yield(static_cache_object(o))} else all.map end end |