0.0
No commit activity in last 3 years
No release in over 3 years
A Ruby 2.1+ refinement that allows Symbol#to_proc to pass args or a block via Symbol#call.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.6
~> 10.1
 Project Readme

SymbolCall

SymbolCall refines Symbol#call to allow Symbol#to_proc take arguments and blocks. This has come up a few times in #ruby on IRC and on https://bugs.ruby-lang.org issues like here and here. So here's a tiny gem called symbol_call that enables this syntax inside of a lexical scope using a refinement.

Installation

gem install symbol_call

Usage

require 'symbol_call'

module Example
  using SymbolCall

  def self.argument
    [1, 2, 3].map &:to_s.(2)
  end

  def self.argument_and_block
    ['XI418', 'XO419'].map &:gsub.(/\d+/) { |n| n.to_i.next }
  end
end

Example.argument
["1", "10", "11"]

Example.argument_and_block
["XI419", "XO420"]

Requirements

SymbolCall requires Ruby 2.1+ for refinements.