Method: Tap::Declarations#namespace

Defined in:
lib/tap/declarations.rb

#namespace(namespace) ⇒ Object

Nests tasks within the named module for the duration of the block. Namespaces may be nested.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/tap/declarations.rb', line 56

def namespace(namespace)
  current = @namespace
  begin
    unless namespace.nil? || namespace.kind_of?(Module)
      const_name = namespace.to_s.camelize
      unless current.const_defined?(const_name)
        current.const_set(const_name, Module.new)
      end
      namespace = current.const_get(const_name)
    end
    
    @namespace = namespace unless namespace.nil?
    yield if block_given?
  ensure
    @namespace = current if block_given?
  end
end