Class: Primalize::Many::Enumerable
- Inherits:
-
Object
- Object
- Primalize::Many::Enumerable
- Defined in:
- lib/primalize/many.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(enumerable) ⇒ Enumerable
constructor
A new instance of Enumerable.
- #validate!(enumerable) ⇒ Object
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
#call ⇒ Object
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 |