Class: As

Inherits:
Object show all
Defined in:
lib/core/facets/kernel/as.rb

Overview

Support class for Kernel#as.

TODO: Deprecate this and use Functor (HigherOrderMessage) instead ?

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (As) initialize(subject, ancestor)

A new instance of As



105
106
107
108
# File 'lib/core/facets/kernel/as.rb', line 105

def initialize(subject, ancestor)
  @subject = subject
  @ancestor = ancestor
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(sym, *args, &blk) (private)



111
112
113
# File 'lib/core/facets/kernel/as.rb', line 111

def method_missing(sym, *args, &blk)
  @ancestor.instance_method(sym).bind(@subject).call(*args,&blk)
end

Class Method Details

+ (Object) new(subject, ancestor) Also known as: _new



90
91
92
# File 'lib/core/facets/kernel/as.rb', line 90

def new(subject, ancestor)
  cache[subject][ancestor] ||= _new(subject, ancestor)
end