Class: Primalize::Many::Enumerable

Inherits:
Object
  • Object
show all
Defined in:
lib/primalize/many.rb

Instance Method Summary collapse

Constructor Details

#initialize(enumerable) ⇒ Enumerable

Returns a new instance of Enumerable.



65
66
67
68
69
# File 'lib/primalize/many.rb', line 65

def initialize enumerable
  validate! enumerable

  @enumerable = enumerable
end

Instance Method Details

#callObject

Raises:

  • (RuntimeError)


77
78
79
80
# File 'lib/primalize/many.rb', line 77

def call
  raise RuntimeError,
    "Called #{inspect}#call. Please use Primalize::Many.enumerable to create primalizers for this."
end

#validate!(enumerable) ⇒ Object



71
72
73
74
75
# File 'lib/primalize/many.rb', line 71

def validate! enumerable
  unless %w(each map).all? { |msg| enumerable.respond_to? msg }
    raise ArgumentError, "#{self.class.inspect} must receive an Enumerable object, received #{enumerable.inspect}"
  end
end