Class: Gorillib::Factory::NonConvertingFactory
- Inherits:
-
BaseFactory
- Object
- BaseFactory
- Gorillib::Factory::NonConvertingFactory
- Defined in:
- lib/gorillib/factories.rb
Overview
A NonConvertingFactory accepts objects that are already native, and throws a mismatch error for anything else.
Direct Known Subclasses
ClassFactory, ExceptionFactory, FalseFactory, ModuleFactory, NilFactory, RangeFactory, TrueFactory
Instance Method Summary collapse
Methods inherited from BaseFactory
blankish?, #initialize, native?, #native?, typename, #typename
Constructor Details
This class inherits a constructor from Gorillib::Factory::BaseFactory
Instance Method Details
#blankish?(obj) ⇒ Boolean
165 |
# File 'lib/gorillib/factories.rb', line 165 def blankish?(obj) obj.nil? ; end |
#receive(obj) ⇒ Object
166 167 168 169 170 171 172 |
# File 'lib/gorillib/factories.rb', line 166 def receive(obj) return nil if blankish?(obj) return obj if native?(obj) mismatched!(obj, "must be an instance of #{product},") rescue NoMethodError => err mismatched!(obj, err., err.backtrace) end |