Class: RakeCommander::RakeContext::Wrapper
- Inherits:
-
Object
- Object
- RakeCommander::RakeContext::Wrapper
- Includes:
- Rake::DSL
- 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
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
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
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
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 |