Class: Jellyfish::Provisioner
- Inherits:
-
Object
- Object
- Jellyfish::Provisioner
- Defined in:
- lib/jellyfish/provisioner.rb,
lib/jellyfish/provisioner/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Attribute Summary collapse
-
#order_item ⇒ Object
readonly
Returns the value of attribute order_item.
Class Method Summary collapse
- .critical_error(order_item, message) ⇒ Object
-
.perform(order_item_id, error_method) ⇒ Object
private.
- .provision(order_item_id) ⇒ Object
- .retire(order_item_id) ⇒ Object
- .warning_retirement_error(order_item, message) ⇒ Object
Instance Method Summary collapse
-
#initialize(order_item) ⇒ Provisioner
constructor
A new instance of Provisioner.
Constructor Details
#initialize(order_item) ⇒ Provisioner
Returns a new instance of Provisioner.
15 16 17 |
# File 'lib/jellyfish/provisioner.rb', line 15 def initialize(order_item) @order_item = order_item end |
Instance Attribute Details
#order_item ⇒ Object (readonly)
Returns the value of attribute order_item.
5 6 7 |
# File 'lib/jellyfish/provisioner.rb', line 5 def order_item @order_item end |
Class Method Details
.critical_error(order_item, message) ⇒ Object
36 37 38 39 |
# File 'lib/jellyfish/provisioner.rb', line 36 def self.critical_error(order_item, ) order_item.provision_status = :critical order_item.status_msg = end |
.perform(order_item_id, error_method) ⇒ Object
private
21 22 23 24 25 26 27 28 29 |
# File 'lib/jellyfish/provisioner.rb', line 21 def self.perform(order_item_id, error_method) order_item = OrderItem.find(order_item_id) yield order_item rescue => e send(error_method, order_item, e.) raise ensure order_item.save! end |
.provision(order_item_id) ⇒ Object
7 8 9 |
# File 'lib/jellyfish/provisioner.rb', line 7 def self.provision(order_item_id) perform(order_item_id, :critical_error) { |order_item| new(order_item).provision } end |
.retire(order_item_id) ⇒ Object
11 12 13 |
# File 'lib/jellyfish/provisioner.rb', line 11 def self.retire(order_item_id) perform(order_item_id, :warning_retirement_error) { |order_item| new(order_item).retire } end |
.warning_retirement_error(order_item, message) ⇒ Object
31 32 33 34 |
# File 'lib/jellyfish/provisioner.rb', line 31 def self.warning_retirement_error(order_item, ) order_item.provision_status = :warning order_item.status_msg = "Retirement failed: #{}"[0..254] end |