Module: PatternMatching::ProcHelpers
- Defined in:
- lib/pattern_matching/proc_helpers.rb
Instance Method Summary collapse
-
#C(symbol) ⇒ Object
C for ‘call’, as in “call method in current context”.
-
#S(symbol) ⇒ Object
S for ‘send’, as in “send message to object”.
Instance Method Details
#C(symbol) ⇒ Object
C for ‘call’, as in “call method in current context”. Allows for prettier Method pattern-matches than method(:sym)
14 15 16 |
# File 'lib/pattern_matching/proc_helpers.rb', line 14 def C(symbol) Proc.new { |obj| self.send(symbol, obj) } end |
#S(symbol) ⇒ Object
S for ‘send’, as in “send message to object”. Allows for prettier Proc pattern-matches than simply :sym.to_proc everywhere
7 8 9 |
# File 'lib/pattern_matching/proc_helpers.rb', line 7 def S(symbol) symbol.to_proc end |