Class: Awsum::Ec2::Region
Instance Attribute Summary collapse
-
#end_point ⇒ Object
readonly
Returns the value of attribute end_point.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#availability_zones ⇒ Object
List the AvailabilityZone(s) of this Region.
-
#initialize(ec2, name, end_point) ⇒ Region
constructor
:nodoc:.
-
#use(&block) ⇒ Object
Operate all Awsum::Ec2 methods against this Region.
Constructor Details
#initialize(ec2, name, end_point) ⇒ Region
:nodoc:
8 9 10 11 12 |
# File 'lib/awsum/ec2/region.rb', line 8 def initialize(ec2, name, end_point) #:nodoc: @ec2 = ec2 @name = name @end_point = end_point end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object (private)
– Will pass all missing methods onto the ec2 object
50 51 52 53 54 |
# File 'lib/awsum/ec2/region.rb', line 50 def method_missing(method_name, *args, &block) use do @ec2.send(method_name, *args, &block) end end |
Instance Attribute Details
#end_point ⇒ Object (readonly)
Returns the value of attribute end_point.
6 7 8 |
# File 'lib/awsum/ec2/region.rb', line 6 def end_point @end_point end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/awsum/ec2/region.rb', line 6 def name @name end |
Instance Method Details
#availability_zones ⇒ Object
List the AvailabilityZone(s) of this Region
15 16 17 18 19 |
# File 'lib/awsum/ec2/region.rb', line 15 def availability_zones use do @ec2.availability_zones end end |
#use(&block) ⇒ Object
Operate all Awsum::Ec2 methods against this Region
Example
ec2.region('eu-west-1').use
ec2.availability_zones #Will give you all the availability zones in the eu-west-1 region
Alternative:
ec2.region('eu-west-1') do |region|
region.availability_zones
end
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/awsum/ec2/region.rb', line 32 def use(&block) if block_given? begin old_host = @ec2.host @ec2.host = end_point block.arity < 1 ? instance_eval(&block) : block[self] ensure @ec2.host = old_host end else @ec2.host = end_point self end end |