Class: RakeCommander::RakeContext::Wrapper

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/rake-commander/rake_context/wrapper.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, **kargs, &block) ⇒ Object

Forward



22
23
24
25
26
27
28
29
30
# File 'lib/rake-commander/rake_context/wrapper.rb', line 22

def method_missing(meth, *args, **kargs, &block)
  if respond_to?(meth)
    context do
      send(meth, *args, **kargs, &block)
    end
  else
    super
  end
end

Instance Method Details

#context(object = global_instance, &block) ⇒ Object

Note:

this prevents subclass overlap methods to be used

Allows to interact with rake

Raises:

  • (ArgumentError)


8
9
10
11
# File 'lib/rake-commander/rake_context/wrapper.rb', line 8

def context(object = global_instance, &block)
  raise ArgumentError, "Block required" unless block_given?
  object.instance_eval(&block)
end

#respond_to?(meth, with_private = true) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/rake-commander/rake_context/wrapper.rb', line 17

def respond_to?(meth, with_private = true)
  global_instance.respond_to?(meth, with_private) || super
end

#respond_to_missing?(meth, *args) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/rake-commander/rake_context/wrapper.rb', line 13

def respond_to_missing?(meth, *args)
  global_instance.send(:respond_to_missing?, meth, *args) || super
end