0.0
No commit activity in last 3 years
No release in over 3 years
LazyMethod is the new way of get method class object
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 10.0
>= 0
 Project Readme

LazyMethod

Build Status

Inspired by https://bugs.ruby-lang.org/issues/12125

Usage

# standard style
foo = Foo.new
foo.bar                          # where is defined this method?
foo.method(:bar).source_location #=> [file.rb, 10]
foo.bar                          # OK remove `method(:` and `).source_location`
# lazy_method style
foo = Foo.new
foo.bar                        # where is defined this method?
foo.method.source_location.bar #=> [file.rb, 10]
foo.bar                        # OMG remove `.method.source_location` only
foo = Foo.new

# make Method object
foo.method(:bar)

# make LazyMethod object
foo.method           #=> #<LazyMethod #<Foo:0x00>>

# make Method object from LazyMethod
foo.method.bar       #=> #<Method: Foo#bar>
foo.method.bar.arity #=> 1

# Lazy call Method method
foo.method.arity     #=>
#<LazyMethod #<Foo:0x00>(arity)>
foo.method.arity.bar #=> 1

Installation

Add this line to your application's Gemfile:

gem 'lazy_method'

And then execute:

$ bundle

Or install it yourself as:

$ gem install lazy_method

License

The gem is available as open source under the terms of the MIT License.