Class: RakeCommander::RakeContext::Wrapper
- Inherits:
-
Object
- Object
- RakeCommander::RakeContext::Wrapper
- Defined in:
- lib/rake-commander/rake_context/wrapper.rb
Instance Method Summary collapse
-
#context(object = global_instance, &block) ⇒ Object
Allows to interact with rake.
-
#method_missing(meth, *args, **kargs, &block) ⇒ Object
Forward.
- #respond_to?(meth, with_private = true) ⇒ Boolean
- #respond_to_missing?(meth, *args) ⇒ Boolean
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, **kargs, &block) ⇒ Object
Forward
20 21 22 23 24 25 26 27 28 |
# File 'lib/rake-commander/rake_context/wrapper.rb', line 20 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
6 7 8 9 |
# File 'lib/rake-commander/rake_context/wrapper.rb', line 6 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
15 16 17 |
# File 'lib/rake-commander/rake_context/wrapper.rb', line 15 def respond_to?(meth, with_private = true) global_instance.respond_to?(meth, with_private) || super end |
#respond_to_missing?(meth, *args) ⇒ Boolean
11 12 13 |
# File 'lib/rake-commander/rake_context/wrapper.rb', line 11 def respond_to_missing?(meth, *args) global_instance.send(:respond_to_missing?, meth, *args) || super end |