Class: Offshore::Controller
- Inherits:
-
Object
- Object
- Offshore::Controller
- Defined in:
- lib/offshore/server/controller.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #factory_create ⇒ Object
-
#initialize(hash) ⇒ Controller
constructor
A new instance of Controller.
- #suite_start ⇒ Object
- #suite_stop ⇒ Object
- #test_start ⇒ Object
- #test_stop ⇒ Object
Constructor Details
#initialize(hash) ⇒ Controller
Returns a new instance of Controller.
4 5 6 |
# File 'lib/offshore/server/controller.rb', line 4 def initialize(hash) @params = hash end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/offshore/server/controller.rb', line 3 def params @params end |
Instance Method Details
#factory_create ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/offshore/server/controller.rb', line 31 def factory_create name = params["name"] raise "Need a factory name" unless name attributes = params["attributes"] || {} clazz = factory_girl require "factory_girl" unless clazz clazz = factory_girl begin val = clazz.create(name, attributes) out = {:class_name => val.class.name, :id => val.id, :attributes => val.attributes} status = 200 rescue ActiveRecord::RecordInvalid => invalid out = {:error => invalid.record.errors..join(",") } status = 422 end [status, out] end |
#suite_start ⇒ Object
8 9 10 11 |
# File 'lib/offshore/server/controller.rb', line 8 def suite_start suite_key_set(params) [200, {"todo" => "log that the suite is running"}] end |
#suite_stop ⇒ Object
13 14 15 16 |
# File 'lib/offshore/server/controller.rb', line 13 def suite_stop suite_key_clear [200, {"action" => "cleared"}] end |