Class: Fog::QingCloud::Model
- Inherits:
-
Model
- Object
- Model
- Fog::QingCloud::Model
- Defined in:
- lib/fog/qingcloud/model.rb
Direct Known Subclasses
Compute::QingCloud::Address, Compute::QingCloud::Flavor, Compute::QingCloud::Image, Compute::QingCloud::KeyPair, Compute::QingCloud::Router, Compute::QingCloud::SecurityGroup, Compute::QingCloud::SecurityGroupRule, Compute::QingCloud::Volume, Compute::QingCloud::Vxnet
Class Method Summary collapse
-
.inherited(child) ⇒ Object
Define a common modify_attributes method for some resources.
Instance Method Summary collapse
Class Method Details
.inherited(child) ⇒ Object
Define a common modify_attributes method for some resources
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fog/qingcloud/model.rb', line 9 def self.inherited(child) resource_type = Fog::QingCloud.underscore_string(child.to_s.split(':').last) aliased_resource_type = { 'server' => 'instance', 'address' => 'eip', 'key_pair' => 'keypair' } resource_type = aliased_resource_type.fetch(resource_type, resource_type) attributes_modifable_resources = ['instance', 'volume', 'vxnet', 'eip', 'security_group', 'keypair', 'image'] if attributes_modifable_resources.include?(resource_type) child.class_eval <<-EOS, __FILE__, __LINE__ def modify_attributes(name, description) requires :id raise Fog::QingCloud::Errors::CommonClientError, "name or description must be specified" unless name || description service.modify_resource_attributes(id, '#{resource_type}', name, description) merge_attributes('#{resource_type}_name' => name, 'description' => description) true end EOS end end |
Instance Method Details
#changing? ⇒ Boolean
38 39 40 41 |
# File 'lib/fog/qingcloud/model.rb', line 38 def changing? respond_to?(:transition_status) && transition_status && !transition_status.empty? end |
#wait_for(&block) ⇒ Object
33 34 35 36 |
# File 'lib/fog/qingcloud/model.rb', line 33 def wait_for(&block) wait_policy = lambda { |retries| retries < 8 ? 9 - retries : 1 } super(Fog::QingCloud.wait_timeout, wait_policy, &block) end |