Class: Description
Defined Under Namespace
Classes: EBS, EC2, ELB, RDS
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(description) ⇒ Description
Returns a new instance of Description.
18
19
20
|
# File 'lib/maws/description.rb', line 18
def initialize(description)
raise "use #{self.class}::create instead"
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
14
15
16
|
# File 'lib/maws/description.rb', line 14
def method_missing(method_name, *args, &block)
description[method_name.to_sym]
end
|
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
2
3
4
|
# File 'lib/maws/description.rb', line 2
def description
@description
end
|
Class Method Details
.create(description) ⇒ Object
4
5
6
7
8
|
# File 'lib/maws/description.rb', line 4
def self.create(description)
service = description[:service]
klass = Description.const_get("#{service.to_s.upcase}")
klass.new(description)
end
|
Instance Method Details
10
11
12
|
# File 'lib/maws/description.rb', line 10
def [](key)
description[key]
end
|
#create_instance(maws, config) ⇒ Object
70
71
72
73
74
|
# File 'lib/maws/description.rb', line 70
def create_instance(maws, config)
instance = Instance.create(maws, config, prefix, zone, role, index, {:service => service, :name => name, :region => region })
instance.description = self
instance
end
|
60
61
62
63
|
# File 'lib/maws/description.rb', line 60
def index
md = name.match(name_re)
md[4].to_i if md
end
|
#logical_zone ⇒ Object
65
66
67
68
|
# File 'lib/maws/description.rb', line 65
def logical_zone
md = name.match(name_re)
md[5] if md
end
|
39
40
41
|
# File 'lib/maws/description.rb', line 39
def name_re
/^(.+\.)?(.+)-(.+)-(\d+)(\w)?$/
end
|
#physical_zone ⇒ Object
zone where the instance really lives this has meaning for RDS with multi-zone = true and for EC2 with region scope
30
31
32
|
# File 'lib/maws/description.rb', line 30
def physical_zone
region_zone[-1,1]
end
|
43
44
45
46
47
|
# File 'lib/maws/description.rb', line 43
def prefix
md = name.match(name_re)
md[1].to_s[0...-1] if md
end
|
49
50
51
52
53
|
# File 'lib/maws/description.rb', line 49
def profile
md = name.match(name_re)
md[2] if md
end
|
34
35
36
37
|
# File 'lib/maws/description.rb', line 34
def region
region_zone[0...-1]
end
|
55
56
57
58
|
# File 'lib/maws/description.rb', line 55
def role
md = name.match(name_re)
md[3] if md
end
|
logical zone (what the zone is according to maws categorization)
23
24
25
26
|
# File 'lib/maws/description.rb', line 23
def zone
logical_zone
end
|