class Rhod::Profile
Public Class Methods
new(name, options={})
click to toggle source
# File lib/rhod/profile.rb, line 4 def initialize(name, options={}) # When creating new profiles, copy from the global default, in case it was customized. if @@profiles[:default] default = @@profiles[:default].dup else default = {} end default.each {|k,v| self[k] = v } options.each {|k,v| self[k] = v } self[:profile_name] = name # Middleware stack construction self[:middleware_stack] = Rhod::Middleware.new if self[:middleware].respond_to?(:call) self[:middleware].call(self[:middleware_stack]) elsif self[:middleware] self[:middleware].each do |klass| self[:middleware_stack].use klass end end self[:middleware_stack].build_stack # Syntax sugar: named .with_#{profile} methods on this class and the module @@profiles[name] = self self.class.__send__(:define_method, :"with_#{name}") do |*args, &block| Rhod::Command.execute(*args, @@profiles[name], &block) end Rhod.class.__send__(:define_method, :"with_#{name}") do |*args, &block| Rhod::Command.execute(*args, @@profiles[name], &block) end self end