Skip to content

Commit b546d7a

Browse files
Use ruby2_keywords for the moment (#205)
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.
1 parent 22ce9de commit b546d7a

File tree

4 files changed

+19
-38
lines changed

4 files changed

+19
-38
lines changed

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ PATH
33
specs:
44
arbre (1.2.1)
55
activesupport (>= 3.0.0, < 6.1)
6+
ruby2_keywords (>= 0.0.2)
67

78
GEM
89
remote: http://rubygems.org/
@@ -190,6 +191,7 @@ GEM
190191
rubocop-ast (0.0.3)
191192
parser (>= 2.7.0.1)
192193
ruby-progressbar (1.10.1)
194+
ruby2_keywords (0.0.2)
193195
sawyer (0.8.1)
194196
addressable (>= 2.3.5, < 2.6)
195197
faraday (~> 0.8, < 1.0)

arbre.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ Gem::Specification.new do |s|
2222
s.required_ruby_version = '>= 2.5'
2323

2424
s.add_dependency("activesupport", ">= 3.0.0", "< 6.1")
25+
s.add_dependency("ruby2_keywords", ">= 0.0.2")
2526
end

lib/arbre/context.rb

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'arbre/element'
2+
require 'ruby2_keywords'
23

34
module Arbre
45

@@ -74,21 +75,11 @@ def respond_to_missing?(method, include_all)
7475
# Webservers treat Arbre::Context as a string. We override
7576
# method_missing to delegate to the string representation
7677
# of the html.
77-
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.a")
78-
def method_missing(method, *args, **kwargs, &block)
79-
if cached_html.respond_to? method
80-
cached_html.send method, *args, **kwargs, &block
81-
else
82-
super
83-
end
84-
end
85-
else
86-
def method_missing(method, *args, &block)
87-
if cached_html.respond_to? method
88-
cached_html.send method, *args, &block
89-
else
90-
super
91-
end
78+
ruby2_keywords def method_missing(method, *args, &block)
79+
if cached_html.respond_to? method
80+
cached_html.send method, *args, &block
81+
else
82+
super
9283
end
9384
end
9485

lib/arbre/element.rb

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'arbre/element/builder_methods'
22
require 'arbre/element/proxy'
33
require 'arbre/element_collection'
4+
require 'ruby2_keywords'
45

56
module Arbre
67

@@ -172,29 +173,15 @@ def clear_children!
172173
# 3. Call the method on the helper object
173174
# 4. Call super
174175
#
175-
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.a")
176-
def method_missing(name, *args, **kwargs, &block)
177-
if current_arbre_element.respond_to?(name)
178-
current_arbre_element.send name, *args, **kwargs, &block
179-
elsif assigns && assigns.has_key?(name)
180-
assigns[name]
181-
elsif helpers.respond_to?(name)
182-
helpers.send(name, *args, **kwargs, &block)
183-
else
184-
super
185-
end
186-
end
187-
else
188-
def method_missing(name, *args, &block)
189-
if current_arbre_element.respond_to?(name)
190-
current_arbre_element.send name, *args, &block
191-
elsif assigns && assigns.has_key?(name)
192-
assigns[name]
193-
elsif helpers.respond_to?(name)
194-
helpers.send(name, *args, &block)
195-
else
196-
super
197-
end
176+
ruby2_keywords def method_missing(name, *args, &block)
177+
if current_arbre_element.respond_to?(name)
178+
current_arbre_element.send name, *args, &block
179+
elsif assigns && assigns.has_key?(name)
180+
assigns[name]
181+
elsif helpers.respond_to?(name)
182+
helpers.send(name, *args, &block)
183+
else
184+
super
198185
end
199186
end
200187

0 commit comments

Comments
 (0)