Sha256: cbb784c7638a3491924d23e8073c2a6b123cfe3ce62fe21be856ab95471d1e54
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true 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 ) %i[ 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rom-6.0.0.alpha1 | lib/rom/array_dataset.rb |