Class: Gorillib::Factory::ApplyProcFactory
- Inherits:
-
ConvertingFactory
- Object
- BaseFactory
- ConvertingFactory
- Gorillib::Factory::ApplyProcFactory
- Defined in:
- lib/gorillib/factories.rb
Overview
Instance Attribute Summary collapse
-
#callable ⇒ Object
readonly
Returns the value of attribute callable.
Instance Method Summary collapse
- #blankish?(obj) ⇒ Boolean
- #convert(obj) ⇒ Object
-
#initialize(callable = nil, options = {}, &block) ⇒ ApplyProcFactory
constructor
A new instance of ApplyProcFactory.
- #native?(val) ⇒ Boolean
Methods inherited from ConvertingFactory
Methods inherited from BaseFactory
blankish?, native?, #receive, #typename, typename
Constructor Details
#initialize(callable = nil, options = {}, &block) ⇒ ApplyProcFactory
Returns a new instance of ApplyProcFactory.
544 545 546 547 548 549 550 551 |
# File 'lib/gorillib/factories.rb', line 544 def initialize(callable=nil, ={}, &block) if block_given? raise ArgumentError, "Pass a block or a value, not both" unless callable.nil? callable = block end @callable = callable super() end |
Instance Attribute Details
#callable ⇒ Object (readonly)
Returns the value of attribute callable.
542 543 544 |
# File 'lib/gorillib/factories.rb', line 542 def callable @callable end |
Instance Method Details
#blankish?(obj) ⇒ Boolean
552 |
# File 'lib/gorillib/factories.rb', line 552 def blankish?(obj) obj.nil? ; end |
#convert(obj) ⇒ Object
554 555 556 |
# File 'lib/gorillib/factories.rb', line 554 def convert(obj) callable.call(obj) end |
#native?(val) ⇒ Boolean
553 |
# File 'lib/gorillib/factories.rb', line 553 def native?(val) false ; end |