Sha256: dea890ca2670047e0d1b892b01365b609d5bff2f3d0e23e7a3b0b218ad5af159
Contents?: true
Size: 1.09 KB
Versions: 31
Compression:
Stored size: 1.09 KB
Contents
require 'rom/initializer' require 'rom/enumerable_dataset' module ROM # A helper module that adds data-proxy behavior to an array-like object # # @see EnumerableDataset # # @api public module ArrayDataset extend DataProxy::ClassMethods include EnumerableDataset # Extends the class with data-proxy behavior # # @api private def self.included(klass) klass.class_eval do extend Initializer include DataProxy param :data end end forward( :*, :+, :-, :compact, :compact!, :flatten, :flatten!, :length, :pop, :reverse, :reverse!, :sample, :size, :shift, :shuffle, :shuffle!, :slice, :slice!, :sort!, :uniq, :uniq!, :unshift, :values_at ) [ :map!, :combination, :cycle, :delete_if, :keep_if, :permutation, :reject!, :select!, :sort_by! ].each do |method| class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{method}(*args, &block) return to_enum unless block self.class.new(data.send(:#{method}, *args, &block), options) end RUBY end end end
Version data entries
31 entries across 31 versions & 2 rubygems