Sha256: 427cb06deedf0af24af59b937decb5d3f1228c93b6eeb5ad2c07613e66f0b1fc
Contents?: true
Size: 741 Bytes
Versions: 2
Compression:
Stored size: 741 Bytes
Contents
module ActiveEnumerable module Base include ::Enumerable def each(*args, &block) @collection.send(:each, *args, &block) end def initialize(collection=[]) active_enumerable_setup(collection) end def active_enumerable_setup(collection=[]) if collection.is_a? ::Enumerator::Lazy @collection = collection else @collection = collection.to_a end end def to_a @collection.to_a end def <<(item) @collection << item end alias_method :add, :<< def all self.tap { to_a } end def name self.class.name end # @private def __new_relation__(collection) self.class.new(collection) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_enumerable-1.1.0 | lib/active_enumerable/base.rb |
active_enumerable-1.0.0 | lib/active_enumerable/base.rb |