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

Fix ruby 2.7 warnings #202

Merged
merged 1 commit into from
May 18, 2020
Merged
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Drop ruby 2.3 support. [#152][] by [@deivid-rodriguez][]
* Drop ruby 2.4 support. [#177][] by [@deivid-rodriguez][]
* Fix ruby 2.7 kwargs warnings. [#202][] by [@deivid-rodriguez][]

## 1.2.1 [☰](https://github.com/activeadmin/arbre/compare/v1.2.0...v1.2.1)

Expand Down Expand Up @@ -88,6 +89,7 @@ Initial release and extraction from Active Admin
[#121]: https://github.com/activeadmin/arbre/pull/121
[#152]: https://github.com/activeadmin/arbre/pull/152
[#177]: https://github.com/activeadmin/arbre/pull/177
[#202]: https://github.com/activeadmin/arbre/pull/202

[@aramvisser]: https://github.com/aramvisser
[@LTe]: https://github.com/LTe
Expand Down
20 changes: 15 additions & 5 deletions lib/arbre/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,21 @@ def respond_to_missing?(method, include_all)
# Webservers treat Arbre::Context as a string. We override
# method_missing to delegate to the string representation
# of the html.
def method_missing(method, *args, &block)
if cached_html.respond_to? method
cached_html.send method, *args, &block
else
super
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.a")
def method_missing(method, *args, **kwargs, &block)
if cached_html.respond_to? method
cached_html.send method, *args, **kwargs, &block
else
super
end
end
else
def method_missing(method, *args, &block)
if cached_html.respond_to? method
cached_html.send method, *args, &block
else
super
end
end
end

Expand Down
32 changes: 23 additions & 9 deletions lib/arbre/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,29 @@ def clear_children!
# 3. Call the method on the helper object
# 4. Call super
#
def method_missing(name, *args, &block)
if current_arbre_element.respond_to?(name)
current_arbre_element.send name, *args, &block
elsif assigns && assigns.has_key?(name)
assigns[name]
elsif helpers.respond_to?(name)
helpers.send(name, *args, &block)
else
super
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.a")
def method_missing(name, *args, **kwargs, &block)
if current_arbre_element.respond_to?(name)
current_arbre_element.send name, *args, **kwargs, &block
elsif assigns && assigns.has_key?(name)
assigns[name]
elsif helpers.respond_to?(name)
helpers.send(name, *args, **kwargs, &block)
else
super
end
end
else
def method_missing(name, *args, &block)
if current_arbre_element.respond_to?(name)
current_arbre_element.send name, *args, &block
elsif assigns && assigns.has_key?(name)
assigns[name]
elsif helpers.respond_to?(name)
helpers.send(name, *args, &block)
else
super
end
end
end

Expand Down