Class: HP::Cloud::BaseHelper
- Inherits:
-
Object
- Object
- HP::Cloud::BaseHelper
- Defined in:
- lib/hpcloud/base_helper.rb
Direct Known Subclasses
AddressHelper, DatabaseHelper, DnsHelper, FloatingIpHelper, ImageHelper, KeypairHelper, NetworkHelper, PortHelper, RuleHelper, SecurityGroupHelper, ServerHelper, SnapshotHelper, SubnetHelper, VolumeHelper
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#cstatus ⇒ Object
Returns the value of attribute cstatus.
-
#fog ⇒ Object
Returns the value of attribute fog.
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(connection, foggy = nil) ⇒ BaseHelper
constructor
A new instance of BaseHelper.
- #is_valid? ⇒ Boolean
- #set_error(noo, status = :general_error) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(connection, foggy = nil) ⇒ BaseHelper
Returns a new instance of BaseHelper.
27 28 29 30 31 |
# File 'lib/hpcloud/base_helper.rb', line 27 def initialize(connection, foggy = nil) @connection = connection @cstatus = CliStatus.new @fog = foggy end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
25 26 27 |
# File 'lib/hpcloud/base_helper.rb', line 25 def connection @connection end |
#cstatus ⇒ Object
Returns the value of attribute cstatus.
25 26 27 |
# File 'lib/hpcloud/base_helper.rb', line 25 def cstatus @cstatus end |
#fog ⇒ Object
Returns the value of attribute fog.
25 26 27 |
# File 'lib/hpcloud/base_helper.rb', line 25 def fog @fog end |
Instance Method Details
#destroy ⇒ Object
51 52 53 |
# File 'lib/hpcloud/base_helper.rb', line 51 def destroy @fog.destroy unless @fog.nil? end |
#is_valid? ⇒ Boolean
47 48 49 |
# File 'lib/hpcloud/base_helper.rb', line 47 def is_valid? return @cstatus.is_success? end |
#set_error(noo, status = :general_error) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/hpcloud/base_helper.rb', line 40 def set_error(noo, status = :general_error) unless noo.is_a?(CliStatus) noo = CliStatus.new(noo, status) end @cstatus.set(noo) end |
#to_hash ⇒ Object
33 34 35 36 37 38 |
# File 'lib/hpcloud/base_helper.rb', line 33 def to_hash return nil unless is_valid? hash = {} instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) } hash end |