Class: Mystro::Organization
- Inherits:
-
Object
- Object
- Mystro::Organization
- Defined in:
- lib/mystro/organization.rb
Class Attribute Summary collapse
-
.selected ⇒ Object
readonly
Returns the value of attribute selected.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #balancer ⇒ Object
- #compute ⇒ Object
-
#initialize(name, file) ⇒ Organization
constructor
A new instance of Organization.
- #record ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(name, file) ⇒ Organization
Returns a new instance of Organization.
45 46 47 48 49 50 51 52 |
# File 'lib/mystro/organization.rb', line 45 def initialize(name, file) cfg = Mystro.config.to_hash organization = File.exists?(file) ? YAML.load_file(file) : {} @name = name @file = file @data = Hashie::Mash.new(cfg.deep_merge(organization)) @data.name = name end |
Class Attribute Details
.selected ⇒ Object (readonly)
Returns the value of attribute selected.
6 7 8 |
# File 'lib/mystro/organization.rb', line 6 def selected @selected end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
41 42 43 |
# File 'lib/mystro/organization.rb', line 41 def data @data end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
42 43 44 |
# File 'lib/mystro/organization.rb', line 42 def file @file end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
43 44 45 |
# File 'lib/mystro/organization.rb', line 43 def name @name end |
Class Method Details
.[](name) ⇒ Object
8 9 10 |
# File 'lib/mystro/organization.rb', line 8 def [](name) get(name) end |
.default ⇒ Object
29 30 31 32 33 34 |
# File 'lib/mystro/organization.rb', line 29 def default return ENV['MYSTRO_ORGANIZATION'] if ENV['MYSTRO_ORGANIZATION'] return Mystro.config.default_organization if Mystro.config.default_organization? return "default" if @list.keys.include?("default") @list.keys.first end |
.get(name) ⇒ Object
12 13 14 |
# File 'lib/mystro/organization.rb', line 12 def get(name) @list[name] end |
.read ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mystro/organization.rb', line 16 def read dir = Mystro.directory @list = {} Dir["#{dir}/organizations/*.y*ml"].each do |file| name = file.gsub(/#{dir}\/organizations\//, "").gsub(/\.(\w+?)$/, "") Mystro::Log.debug "loading organization '#{name}' '#{file}'" @list[name] = self.new(name, file) end @selected = default end |
.select(name) ⇒ Object
36 37 38 |
# File 'lib/mystro/organization.rb', line 36 def select(name) @selected = name end |
Instance Method Details
#balancer ⇒ Object
62 63 64 |
# File 'lib/mystro/organization.rb', line 62 def balancer @balancer ||= connect(:balancer) end |
#compute ⇒ Object
58 59 60 |
# File 'lib/mystro/organization.rb', line 58 def compute @compute ||= connect(:compute) end |
#record ⇒ Object
66 67 68 |
# File 'lib/mystro/organization.rb', line 66 def record @dns ||= connect(:record) end |
#to_hash ⇒ Object
54 55 56 |
# File 'lib/mystro/organization.rb', line 54 def to_hash @data.to_hash end |