Class: Gorillib::Factory::ApplyProcFactory

Inherits:
ConvertingFactory show all
Defined in:
lib/gorillib/model/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.



536
537
538
539
540
541
542
543
# File 'lib/gorillib/model/factories.rb', line 536

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.



534
535
536
# File 'lib/gorillib/model/factories.rb', line 534

def callable
  @callable
end

Instance Method Details

#blankish?(obj) ⇒ Boolean

Returns:

  • (Boolean)


544
# File 'lib/gorillib/model/factories.rb', line 544

def blankish?(obj)    obj.nil? ; end

#convert(obj) ⇒ Object



546
547
548
# File 'lib/gorillib/model/factories.rb', line 546

def convert(obj)
  callable.call(obj)
end

#native?(val) ⇒ Boolean

Returns:

  • (Boolean)


545
# File 'lib/gorillib/model/factories.rb', line 545

def native?(val)      false    ; end