Giter Site home page Giter Site logo

ruby_memoized's People

Contributors

kklimuk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

tvl2386 zekenie

ruby_memoized's Issues

wrong number of arguments (given 1, expected 0) (ArgumentError)

Hi kklimuk,

Thanks for your awesome blog post and this nifty piece of software.
I've been solving this problem countless times as well. I like your implementation! Specifically because you can just toggle it on and off where you like.

The issue I have is minor and I see why it happens. When I memoize a method that does not have arguments, it doesn't work, see example:

require 'ruby_memoized'

class MyExample
  include RubyMemoized

  memoized

  def hello
    puts "hello world"
  end
end

MyExample.new.hello

Output:

$ ruby test_memoization.rb 
Traceback (most recent call last):
	3: from test_memoization.rb:13:in `<main>'
	2: from /home/tom/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/ruby_memoized-0.1.3/lib/ruby_memoized.rb:37:in `block in method_added'
	1: from /home/tom/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/ruby_memoized-0.1.3/lib/ruby_memoized/memoizer.rb:12:in `call'
test_memoization.rb:8:in `hello': wrong number of arguments (given 1, expected 0) (ArgumentError)

I understand it has to do with your scoped support. It would be great if this could be solved or if another memoization method could be added for this scenario.

Thanks for the big explanation. I can definitely use your code to implement exactly what I need, but maybe ruby_memoized could be even better (imho).

Kind regards,
TvL2386

Deprecation warning with Ruby 2.7+

Hi @kklimuk -- really appreciate this utility / gem. I am attempting an upgrade to Ruby 2.7 in my own projects and receive a deprecation warning from the gem of:

ruby_memoized-0.1.2/lib/ruby_memoized/memoizer.rb:12: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call

I'm not sure if you've seen it already or read the Ruby 2.7 deprecation announcement regarding the keyword args. I found this blog post helpful when upgrading our codebase: https://blog.bigbinary.com/2020/04/14/ruby-2-7-deprecates-conversion-of-keyword-arguments.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.