Sha256: f93580918272de1d26a9b337cb05da2d94e53ae8744ff8c204091899710329d1

Contents?: true

Size: 454 Bytes

Versions: 1

Compression:

Stored size: 454 Bytes

Contents

module PatternMatching
  module ProcHelpers

    ##
    # S for 'send', as in "send message to object".
    # Allows for prettier Proc pattern-matches than simply :sym.to_proc everywhere
    def S(symbol)
      symbol.to_proc
    end

    ##
    # C for 'call', as in "call method in current context".
    # Allows for prettier Method pattern-matches than method(:sym)
    def C(symbol)
      Proc.new { |obj| self.send(symbol, obj) }
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pattern_matching-0.1.0 lib/pattern_matching/proc_helpers.rb