Module: CORL::Mixin::Builder::Global
- Included in:
- Instance, Plugin::Builder, Plugin::Provisioner
- Defined in:
- lib/core/mixin/builder.rb
Overview
Extend
Instance Method Summary collapse
-
#concatenate(components, capitalize = false, joiner = nil) ⇒ Object
—.
-
#id(name = nil) ⇒ Object
—————————————————————————– Utilities.
-
#id_joiner ⇒ Object
—.
-
#process_environment(settings, environment = nil) ⇒ Object
—.
-
#resource(name = nil, capitalize = false) ⇒ Object
—.
-
#resource_joiner ⇒ Object
—————————————————————————– Accessors / modifiers.
Instance Method Details
#concatenate(components, capitalize = false, joiner = nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/core/mixin/builder.rb', line 43 def concatenate(components, capitalize = false, joiner = nil) joiner = resource_joiner unless joiner if components.is_a?(Array) components = components.collect do |str| str.to_s.split(id_joiner) end.flatten else components = [ components.to_s.split(id_joiner) ].flatten end if capitalize name = components.collect {|str| str.capitalize }.join(joiner) else name = components.join(joiner) end name end |
#id(name = nil) ⇒ Object
Utilities
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/core/mixin/builder.rb', line 23 def id(name = nil) name = 'unknown' if name.nil? name = [ name ] unless name.is_a?(Array) components = [] name.flatten.each do |component| components << component.to_s.gsub(resource_joiner, id_joiner) end components.join(id_joiner).to_sym end |
#id_joiner ⇒ Object
16 17 18 |
# File 'lib/core/mixin/builder.rb', line 16 def id_joiner '__' end |
#process_environment(settings, environment = nil) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/core/mixin/builder.rb', line 64 def process_environment(settings, environment = nil) config = Config.new(hash(settings)) env_config = config.delete(:environment) environment = environment.to_sym if environment if env_config if environment && env_config.has_key?(environment) local_env_config = env_config[environment] while local_env_config && local_env_config.has_key?(:use) do local_env_config = env_config[local_env_config[:use].to_sym] end config.defaults(local_env_config) if local_env_config end config.defaults(env_config[:default]) if env_config.has_key?(:default) end config.export end |
#resource(name = nil, capitalize = false) ⇒ Object
36 37 38 39 |
# File 'lib/core/mixin/builder.rb', line 36 def resource(name = nil, capitalize = false) name = 'unknown' if name.nil? concatenate(name, capitalize, resource_joiner) end |
#resource_joiner ⇒ Object
Accessors / modifiers
10 11 12 |
# File 'lib/core/mixin/builder.rb', line 10 def resource_joiner '::' end |