Module: AndAnd::ObjectGoodies

Included in:
Object
Defined in:
lib/patches/andand.rb

Overview

:nocov:

Instance Method Summary collapse

Instance Method Details

#andand(p = nil) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/patches/andand.rb', line 42

def andand (p = nil)
  if self
    if block_given?
      yield(self)
    elsif p
      p.to_proc.call(self)
    else
      self
    end
  else
    if block_given? or p
      self
    else
      MockReturningMe.new(self)
    end
  end
end

#me(p = nil) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/patches/andand.rb', line 60

def me (p = nil)
  if block_given?
    yield(self)
    self
  elsif p
    p.to_proc.call(self)
    self
  else
    ProxyReturningMe.new(self)
  end
end