Sha256: 4fee32c1bc7b0f33bec3bd93b87ec850efb3929493231fd7ded42990473667ee

Contents?: true

Size: 871 Bytes

Versions: 2

Compression:

Stored size: 871 Bytes

Contents

module Capitate
  
  module CapExt
    
    module Namespace
      
      def self.included(base) #:nodoc:
        unless base.method_defined?(:task_without_capitate)
          base.send :alias_method, :task_without_capitate, :task
          base.send :alias_method, :task, :task_with_capitate
        end
      end
      
      def task_arg(name, desc, options = {})
        @next_task_arguments ||= []
        @next_task_arguments << options.merge({ :name => name, :desc => desc })
      end
      
      def task_with_capitate(name, options={}, &block)
        task_without_capitate(name, options) do
          find_task(name).setup_defaults
          block.call
        end
        task_def = find_task(name)        
        task_def.arguments = @next_task_arguments
        @next_task_arguments = nil
        task_def
      end
            
    end
    
  end
  
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
calas-capitate-0.3.6 lib/capitate/cap_ext/namespace.rb
capitate-0.3.6 lib/capitate/cap_ext/namespace.rb