Class: Bcome::Stack::Platform

Inherits:
Object
  • Object
show all
Includes:
BecomeObject
Defined in:
lib/stack/platform.rb

Constant Summary

Constants included from BecomeObject

BecomeObject::CONFIGS_PATH

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BecomeObject

#all_items, #become_identifier, #do_load_resources, #has_main_context?, #list, #main_context, #main_context=, #previous_workspace_object, #previous_workspace_object=, #resource_for_identifier, #resources, #responds_to_list?

Constructor Details

#initialize(identifier, meta_data) ⇒ Platform

Returns a new instance of Platform.



20
21
22
23
24
# File 'lib/stack/platform.rb', line 20

def initialize(identifier, )
  @identifier = identifier
   = 
  @quick_contexts = [:quick_contexts]
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



17
18
19
# File 'lib/stack/platform.rb', line 17

def identifier
  @identifier
end

#quick_contextsObject (readonly)

Returns the value of attribute quick_contexts.



18
19
20
# File 'lib/stack/platform.rb', line 18

def quick_contexts
  @quick_contexts
end

Class Method Details

.collection_from_config(parent, configuration) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/stack/platform.rb', line 7

def collection_from_config(parent, configuration)
  return unless configuration
  collection = []
  configuration.each do |conf_data|
    collection << new(conf_data[:name], conf_data)
  end
  return collection
end

Instance Method Details

#collection_keyObject



46
47
48
# File 'lib/stack/platform.rb', line 46

def collection_key
  :environments
end

#collection_klassObject



38
39
40
# File 'lib/stack/platform.rb', line 38

def collection_klass
  ::ENV_STACK_KLASS
end

#config_pathObject



34
35
36
# File 'lib/stack/platform.rb', line 34

def config_path
  "#{CONFIGS_PATH}/network.yml"
end

#do_describeObject



30
31
32
# File 'lib/stack/platform.rb', line 30

def do_describe
  "#{identifier}\n - #{@meta_data[:description]}\n"
end

#has_quick_contexts?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/stack/platform.rb', line 50

def has_quick_contexts?
  return !quick_contexts.nil?
end


26
27
28
# File 'lib/stack/platform.rb', line 26

def menu_items
  super
end

#quick_context_for_reference(context_reference) ⇒ Object



54
55
56
57
58
59
# File 'lib/stack/platform.rb', line 54

def quick_context_for_reference(context_reference)
  return nil unless has_quick_contexts?
  matches = quick_contexts.select{|qc| qc[:ref] == context_reference }
  raise "Multiple quick context matches found on platform #{@identifier} for context key #{context_reference}. Cannot load quick context - selection is ambiguous." if matches.size > 1
  return matches.first 
end

#reference_keyObject



42
43
44
# File 'lib/stack/platform.rb', line 42

def reference_key
  :platforms
end