Class: Shorthand::Provider
- Inherits:
-
Object
- Object
- Shorthand::Provider
- Defined in:
- lib/shorthand.rb
Instance Method Summary collapse
-
#initialize(target, &block) ⇒ Provider
constructor
A new instance of Provider.
- #method_missing(meth, *args, &block) ⇒ Object
Constructor Details
#initialize(target, &block) ⇒ Provider
Returns a new instance of Provider.
28 29 30 31 32 33 34 35 |
# File 'lib/shorthand.rb', line 28 def initialize(target, &block) @target = target if block.arity == 1 yield self else instance_eval(&block) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/shorthand.rb', line 36 def method_missing(meth, *args, &block) if @target.respond_to?( = "#{meth}=", true) @target.__send__(, *args, &block) else super end end |