Class: Gorillib::Factory::ApplyProcFactory

Inherits:
ConvertingFactory show all
Defined in:
lib/gorillib/factories.rb

Overview


Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ConvertingFactory

#receive

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, options={}, &block)
  if block_given?
    raise ArgumentError, "Pass a block or a value, not both" unless callable.nil?
    callable = block
  end
  @callable = callable
  super(options)
end

Instance Attribute Details

#callableObject (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

Returns:

  • (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

Returns:

  • (Boolean)


553
# File 'lib/gorillib/factories.rb', line 553

def native?(val)      false    ; end