Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrease number of deprecation warnings in Ruby 2.7 #496

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/cell/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def self.included(base)

module ClassMethods
def build(*args)
build!(self, *args).new(*args) # Declarative::Builder#build!.
build!(self, *args, **{}).new(*args) # Declarative::Builder#build!.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is an appropriate fix, but it seems to work!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you guys using Cells' builder features, and if yes, what do your builders look like?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we are not using them. I just found this by running the tests with ruby 2.7 and the tests still pass for ruby 3 so I think this may work.

end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/cell/caching.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def render_state(state, *args, **kws)
key = self.class.state_cache_key(state, self.class.version_procs[state].(*cache_filter_args, exec_context: self))
options = self.class.cache_options[state].(*cache_filter_args, exec_context: self)

fetch_from_cache_for(key, options) { super(state, *cache_filter_args) }
fetch_from_cache_for(key, options) { super(state, *cache_filter_args, **kws) }
end

def cache_store # we want to use DI to set a cache store in cell/rails.
Expand Down
4 changes: 2 additions & 2 deletions lib/cell/view_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def self.controller_path

module Helpers
# Constantizes name if needed, call builders and returns instance.
def cell(name, *args, **kws, &block) # classic Rails fuzzy API.
def cell(name, *args, &block) # classic Rails fuzzy API.
constant = name.is_a?(Class) ? name : class_from_cell_name(name)
constant.(*args, **kws, &block)
constant.(*args, &block)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What warning does removing **kws resolve for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the warning we got:

/home/richard/.rvm/gems/ruby-2.7.5/bundler/gems/cells-88796e3a29cb/lib/cell/view_model.rb:67: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/home/richard/.rvm/gems/ruby-2.7.5/bundler/gems/cells-88796e3a29cb/lib/cell/view_model.rb:31: warning: The called method `cell' is defined here

I was wondering why it wasn't failing with ruby 3 and figured out that those keyword arguments are not used because the instance method cell helper was passing the option as a positional argument anyways (so the kws hash would always be empty in ruby 3).

end
end
extend Helpers
Expand Down