Sha256: 7acbc06b2e7ac15ffc3859c66cf00b2f9c60bb8490bda40762a0c055df935f0f

Contents?: true

Size: 1.8 KB

Versions: 6

Compression:

Stored size: 1.8 KB

Contents

=begin rdoc
  This overwriting of the Capistrano method missing allows our capistrano
  tasks to have access to the methods on the provisioner and options
  set on the clouds. This saves us the responsibility of setting variables
  in the dynamic cap file.
=end
#TODO# Clean up
module Capistrano
  class Configuration
    attr_accessor :cloud, :provisioner
    
    def method_missing_without_variables(sym, *args, &block)
      if parent.respond_to?(sym)
        parent.send(sym, *args, &block)
      elsif provisioner.respond_to?(sym)
        provisioner.send(sym, *args, &block)
      elsif cloud.respond_to?(sym)
        cloud.send(sym, *args, &block)
      elsif PoolParty::Base.options.has_key?(sym)
        PoolParty::Base.options[sym]
      elsif PoolParty::Base.respond_to?(sym)
        PoolParty::Base.send(sym, *args, &block)
      else
        super
      end
    end
      
    
    module Namespaces            
      class Namespace        
        
        def provisioner
          parent.provisioner
        end
        
        def cloud(name=nil)
          puts "name: #{name}"
          name ? get_cloud(name) : parent.cloud
        end
        
        def get_cloud(name)
          PoolParty::Cloud.cloud(name)
        end  
        
        def method_missing(sym, *args, &block)
          if parent.respond_to?(sym)
            parent.send(sym, *args, &block)
          elsif provisioner.respond_to?(sym)
            provisioner.send(sym, *args, &block)
          elsif cloud.respond_to?(sym)
            cloud.send(sym, *args, &block)
          elsif PoolParty::Base.options.has_key?(sym)
            PoolParty::Base.options[sym]
          elsif PoolParty::Base.respond_to?(sym)
            PoolParty::Base.send(sym, *args, &block)
          else
            super
          end
        end
      end
    end    
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
auser-poolparty-0.2.90 lib/poolparty/provisioners/capistrano/capistrano_configurer.rb
auser-poolparty-0.2.91 lib/poolparty/provisioners/capistrano/capistrano_configurer.rb
auser-poolparty-0.2.92 lib/poolparty/provisioners/capistrano/capistrano_configurer.rb
auser-poolparty-0.2.93 lib/poolparty/provisioners/capistrano/capistrano_configurer.rb
auser-poolparty-0.2.94 lib/poolparty/provisioners/capistrano/capistrano_configurer.rb
auser-poolparty-1.0.0 lib/poolparty/provisioners/capistrano/capistrano_configurer.rb