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.
478
479
480
481
482
|
# File 'lib/gorillib/model/factories.rb', line 478
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
476
477
478
|
# File 'lib/gorillib/model/factories.rb', line 476
def items_factory
@items_factory
end
|
Instance Method Details
#blankish?(obj) ⇒ Boolean
484
|
# File 'lib/gorillib/model/factories.rb', line 484
def blankish?(obj) obj.nil? ; end
|
#convert(obj) ⇒ Object
491
492
493
494
495
496
497
|
# File 'lib/gorillib/model/factories.rb', line 491
def convert(obj)
clxn = empty_product
obj.each do |val|
clxn << items_factory.receive(val)
end
clxn
end
|
#empty_product ⇒ Object
487
488
489
|
# File 'lib/gorillib/model/factories.rb', line 487
def empty_product
@product.new
end
|
#native?(obj) ⇒ Boolean
485
|
# File 'lib/gorillib/model/factories.rb', line 485
def native?(obj) false ; end
|