Class: Endeca::Factory
Overview
Endeca::Factory creates stubbed Endeca objects. It expects a hash (or array of hashes) and the class of the Document object(s) to be created.
Constant Summary collapse
- VERSION =
:nodoc:
"0.4.0"
Instance Attribute Summary collapse
-
#objects ⇒ Object
readonly
:nodoc:.
Class Method Summary collapse
-
.create(params, klass) ⇒ Object
Creates stubbed Endeca::Document and Endeca::DocumentCollection objects.
-
.version ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#initialize(params, klass) ⇒ Factory
constructor
:nodoc:.
Constructor Details
#initialize(params, klass) ⇒ Factory
:nodoc:
17 18 19 20 21 22 23 24 25 |
# File 'lib/endeca_factory.rb', line 17 def initialize(params, klass) #:nodoc: params = params.dup @klass = klass case params when Hash; @objects = build_from_hash(params) when Array; @objects = build_from_array(params) else; raise ArgumentError, "Unable to build a(n) #{klass.name} from #{objects.inspect}" end end |
Instance Attribute Details
#objects ⇒ Object (readonly)
:nodoc:
15 16 17 |
# File 'lib/endeca_factory.rb', line 15 def objects @objects end |
Class Method Details
.create(params, klass) ⇒ Object
Creates stubbed Endeca::Document and Endeca::DocumentCollection objects. Pass a hash to return a single stubbed Endeca::Document object or an array of hashes to return an Endeca::DocumentCollection object with documents
stubbed to return the collection of documents built from the array of hashes.
Example:
Endeca::Factory.create({:title => "A Title"}, Listing)
35 36 37 |
# File 'lib/endeca_factory.rb', line 35 def self.create(params, klass) new(params, klass).objects end |