Skip to content

Commit

Permalink
Use ruby2_keywords for the moment
Browse files Browse the repository at this point in the history
Without this gem, current activeadmin version becomes incompatible with
the master branch of `arbre`. It shouldn't be an issue as long as we
update activeadmin's code to use keyword arguments everywhere, set a
minimum dependency on the next `arbre` and release both gems at the same
time, but I think it's easier to be conservative.
  • Loading branch information
deivid-rodriguez committed May 20, 2020
1 parent 7d36b34 commit ea28993
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 38 deletions.
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PATH
specs:
arbre (1.2.1)
activesupport (>= 3.0.0, < 6.1)
ruby2_keywords (>= 0.0.2)

GEM
remote: http://rubygems.org/
Expand Down Expand Up @@ -187,6 +188,7 @@ GEM
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
ruby-progressbar (1.10.1)
ruby2_keywords (0.0.2)
sawyer (0.8.1)
addressable (>= 2.3.5, < 2.6)
faraday (~> 0.8, < 1.0)
Expand Down
1 change: 1 addition & 0 deletions arbre.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 2.5'

s.add_dependency("activesupport", ">= 3.0.0", "< 6.1")
s.add_dependency("ruby2_keywords", ">= 0.0.2")
end
20 changes: 5 additions & 15 deletions lib/arbre/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,11 @@ 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.
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
ruby2_keywords def method_missing(method, *args, &block)
if cached_html.respond_to? method
cached_html.send method, *args, &block
else
super
end
end

Expand Down
32 changes: 9 additions & 23 deletions lib/arbre/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,29 +172,15 @@ def clear_children!
# 3. Call the method on the helper object
# 4. Call 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
ruby2_keywords 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

Expand Down

0 comments on commit ea28993

Please sign in to comment.