Class: Gorillib::Factory::EnumerableFactory
Instance Attribute Summary collapse
Instance Method Summary
collapse
#receive
Methods inherited from BaseFactory
blankish?, native?, #receive, #typename, typename
Constructor Details
Returns a new instance of EnumerableFactory.
486
487
488
489
490
|
# File 'lib/gorillib/factories.rb', line 486
def initialize(options={})
@items_factory = Gorillib::Factory( options.delete(:items){ :identical } )
redefine(:empty_product, options.delete(:empty_product)) if options.has_key?(:empty_product)
super(options)
end
|
Instance Attribute Details
#items_factory ⇒ Object
[#receive] factory for converting items
484
485
486
|
# File 'lib/gorillib/factories.rb', line 484
def items_factory
@items_factory
end
|
Instance Method Details
#blankish?(obj) ⇒ Boolean
492
|
# File 'lib/gorillib/factories.rb', line 492
def blankish?(obj) obj.nil? ; end
|
#convert(obj) ⇒ Object
499
500
501
502
503
504
505
|
# File 'lib/gorillib/factories.rb', line 499
def convert(obj)
clxn = empty_product
obj.each do |val|
clxn << items_factory.receive(val)
end
clxn
end
|
#empty_product ⇒ Object
495
496
497
|
# File 'lib/gorillib/factories.rb', line 495
def empty_product
@product.new
end
|
#native?(obj) ⇒ Boolean
493
|
# File 'lib/gorillib/factories.rb', line 493
def native?(obj) false ; end
|