Module: LazyEnumerable

Included in:
Graphene::OverX, Graphene::ResultSet
Defined in:
lib/lazy_enumerable.rb

Overview

Includes Enumerable and alculates @results lazily. An enumerate! method must be implemented.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:



3
4
5
# File 'lib/lazy_enumerable.rb', line 3

def self.included(base) # :nodoc:
  base.send(:include, Enumerable)
end

Instance Method Details

#==(other) ⇒ Object

Tests equality between this and another set



14
15
16
17
# File 'lib/lazy_enumerable.rb', line 14

def ==(other)
  lazily_enumerate!
  to_a == other.to_a
end

#===(other) ⇒ Object

Tests equality between this and another set



20
21
22
23
# File 'lib/lazy_enumerable.rb', line 20

def ===(other)
  lazily_enumerate!
  to_a === other.to_a
end

#each(&block) ⇒ Object

Implements the “each” method required by Enumerable.



8
9
10
11
# File 'lib/lazy_enumerable.rb', line 8

def each(&block)
  lazily_enumerate!
  @results.each &block
end