Class: AnswerFactory::Factory
- Inherits:
-
Object
- Object
- AnswerFactory::Factory
- Defined in:
- lib/factories/factory.rb
Instance Attribute Summary collapse
-
#couchdb_name ⇒ Object
readonly
Returns the value of attribute couchdb_name.
-
#couchdb_server ⇒ Object
readonly
Returns the value of attribute couchdb_server.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nudge_instructions ⇒ Object
readonly
Returns the value of attribute nudge_instructions.
-
#nudge_types ⇒ Object
readonly
Returns the value of attribute nudge_types.
-
#original_options_hash ⇒ Object
readonly
Returns the value of attribute original_options_hash.
-
#workstation_names ⇒ Object
Returns the value of attribute workstation_names.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Factory
constructor
A new instance of Factory.
- #training_datasource ⇒ Object
-
#update_configatron! ⇒ Object
this apparent redundancy saves project-based and command-line overrides.
Constructor Details
#initialize(options = {}) ⇒ Factory
Returns a new instance of Factory.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/factories/factory.rb', line 13 def initialize( = {}) # Factory instance settings @name = [:name] || configatron.factory.retrieve(:name,nil) || "my_factory" @workstation_names = [:workstation_names] || configatron.factory.retrieve(:workstation_names, nil) || Array.new # CouchDB settings @couchdb_server = [:couchdb_server] || configatron.factory.couchdb.retrieve(:server, nil) || "http://127.0.0.1:5984" @couchdb_name = [:couchdb_name] || configatron.factory.couchdb.retrieve(:name, nil) || @name # Nudge language settings @nudge_instructions = [:nudge_instructions] || configatron.nudge.instructions.retrieve(:all, nil) || Instruction.all_instructions @nudge_types = [:nudge_types] || configatron.nudge.types.retrieve(:all, nil) || NudgeType.all_types update_configatron! end |
Instance Attribute Details
#couchdb_name ⇒ Object (readonly)
Returns the value of attribute couchdb_name.
8 9 10 |
# File 'lib/factories/factory.rb', line 8 def couchdb_name @couchdb_name end |
#couchdb_server ⇒ Object (readonly)
Returns the value of attribute couchdb_server.
8 9 10 |
# File 'lib/factories/factory.rb', line 8 def couchdb_server @couchdb_server end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/factories/factory.rb', line 5 def name @name end |
#nudge_instructions ⇒ Object (readonly)
Returns the value of attribute nudge_instructions.
6 7 8 |
# File 'lib/factories/factory.rb', line 6 def nudge_instructions @nudge_instructions end |
#nudge_types ⇒ Object (readonly)
Returns the value of attribute nudge_types.
7 8 9 |
# File 'lib/factories/factory.rb', line 7 def nudge_types @nudge_types end |
#original_options_hash ⇒ Object (readonly)
Returns the value of attribute original_options_hash.
10 11 12 |
# File 'lib/factories/factory.rb', line 10 def @original_options_hash end |
#workstation_names ⇒ Object
Returns the value of attribute workstation_names.
9 10 11 |
# File 'lib/factories/factory.rb', line 9 def workstation_names @workstation_names end |
Class Method Details
.couch_available? ⇒ Boolean
63 64 65 66 67 68 |
# File 'lib/factories/factory.rb', line 63 def self.couch_available? open(configatron.factory.couchdb.server).status true rescue StandardError false end |
Instance Method Details
#training_datasource ⇒ Object
70 71 72 |
# File 'lib/factories/factory.rb', line 70 def training_datasource "#{@couchdb_server}/#{@name}_training" end |
#update_configatron! ⇒ Object
this apparent redundancy saves project-based and command-line overrides
52 53 54 55 56 57 58 59 60 |
# File 'lib/factories/factory.rb', line 52 def update_configatron! configatron.factory.name = @name configatron.nudge.instructions.all = @nudge_instructions configatron.nudge.types.all = @nudge_types configatron.factory.workstation_names = @workstation_names configatron.factory.couchdb.server = @couchdb_server configatron.factory.couchdb.name = @couchdb_name configatron.factory.training_datasource = self.training_datasource end |