Skip to content

Commit c6b960a

Browse files
committed
Code cleanup and commenting for the sake of documentation
1 parent f594af1 commit c6b960a

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

lib/softlayer/VirtualServerUpgradeOrder.rb

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# For licensing information see the LICENSE.md file in the project root.
55
#++
66

7-
87
module SoftLayer
98
# This class is used to order changes to a virtual server. Although
109
# the class is named "upgrade" this class can also be used for "downgrades"
@@ -35,11 +34,21 @@ class VirtualServerUpgradeOrder
3534
# will be performed immediately
3635
attr_accessor :upgrade_at
3736

37+
##
38+
# Create an upgrade order for the virtual server provided.
39+
#
3840
def initialize(virtual_server)
3941
raise "A virtual server must be provided at the time a virtual server order is created" if !virtual_server || !virtual_server.kind_of?(SoftLayer::VirtualServer)
4042
@virtual_server = virtual_server
4143
end
4244

45+
##
46+
# Sends the order represented by this object to SoftLayer for validation.
47+
#
48+
# If a block is passed to verify, the code will send the order template
49+
# being constructed to the block before the order is actually sent for
50+
# validation.
51+
#
4352
def verify()
4453
if has_order_items?
4554
order_object = self.order_object
@@ -49,6 +58,13 @@ def verify()
4958
end
5059
end
5160

61+
##
62+
# Places the order represented by this object. This is likely to
63+
# involve a change to the charges on an account.
64+
#
65+
# If a block is passed to this routine, the code will send the order template
66+
# being constructed to that block before the order is sent
67+
#
5268
def place_order!()
5369
if has_order_items?
5470
order_object = self.order_object
@@ -78,10 +94,16 @@ def max_port_speed_options(client = nil)
7894

7995
private
8096

97+
##
98+
# Returns true if this order object has any upgrades specified
99+
#
81100
def has_order_items?
82101
@cores != nil || @ram != nil || @max_port_speed != nil
83102
end
84103

104+
##
105+
# Returns a list of the update item prices, in the given category, for the server
106+
#
85107
def _item_prices_in_category(which_category)
86108
@virtual_server.upgrade_options.select { |item_price| item_price["categories"].find { |category| category["categoryCode"] == which_category } }
87109
end
@@ -94,6 +116,9 @@ def _item_price_with_capacity(which_category, capacity)
94116
self._item_prices_in_category(which_category).find { |item_price| item_price["item"]["capacity"].to_i == capacity}
95117
end
96118

119+
##
120+
# construct an order object
121+
#
97122
def order_object
98123
prices = []
99124

0 commit comments

Comments
 (0)