Class: Double::Klass
- Inherits:
- BasicObject
- Extended by:
- Forwardable
- Defined in:
- lib/double.rb
Instance Method Summary collapse
- #_ ⇒ Object
-
#initialize(name) ⇒ Klass
constructor
A new instance of Klass.
- #method_missing(mth, *args, &blk) ⇒ Object
Constructor Details
#initialize(name) ⇒ Klass
Returns a new instance of Klass.
16 17 18 |
# File 'lib/double.rb', line 16 def initialize(name) @name = name end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(mth, *args, &blk) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/double.rb', line 24 def method_missing(mth, *args, &blk) if _.respond_to? mth (class << self; self; end).instance_eval do def_delegator :@_, mth end @_.send mth, *args, &blk else super end end |
Instance Method Details
#_ ⇒ Object
20 21 22 |
# File 'lib/double.rb', line 20 def _ @_ ||= ::Kernel.const_get @name end |