Class: AndAnd

Inherits:
Object show all
Defined in:
lib/andand2.rb

Constant Summary collapse

@@and_and_nil =
nil

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ AndAnd

Returns a new instance of AndAnd.



26
27
28
# File 'lib/andand2.rb', line 26

def initialize(contents)
  @_obj = contents
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/andand2.rb', line 30

def method_missing(sym, *args)
  if @_obj.respond_to?(sym)
    AndAnd.new(@_obj.send(sym, *args))
  else 
    AndAnd.new(@@and_and_nil)
  end
end

Class Method Details

.method_missing(sym, *args) ⇒ Object



18
19
20
# File 'lib/andand2.rb', line 18

def @@and_and_nil.method_missing(sym, *args)
  @@and_and_nil
end

.unbind(andanded) ⇒ Object



38
39
40
41
# File 'lib/andand2.rb', line 38

def self.unbind(andanded)
  x = andanded.instance_eval("@_obj")
  x == @@and_and_nil ? nil : x
end

Instance Method Details

#inspectObject



22
23
24
# File 'lib/andand2.rb', line 22

def inspect
  @_obj.inspect
end