Skip to content

Commit

Permalink
Fix kwargs for Ruby 2.7 (#885)
Browse files Browse the repository at this point in the history
* Fix kwargs for Ruby 2.7

* Test with Ruby 3.0

Co-authored-by: Nicolas Rodriguez <nicoladmin@free.fr>
  • Loading branch information
oieioi and n-rodriguez committed Jan 27, 2021
1 parent da6cd97 commit 9cb42f6
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
fail-fast: false
matrix:
ruby:
- '3.0'
- '2.7'
- '2.6'
- '2.5'
Expand Down
1 change: 1 addition & 0 deletions draper.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Gem::Specification.new do |s|
s.add_dependency 'request_store', '>= 1.0'
s.add_dependency 'activemodel', '>= 5.0'
s.add_dependency 'activemodel-serializers-xml', '>= 1.0'
s.add_dependency 'ruby2_keywords'

s.add_development_dependency 'ammeter'
s.add_development_dependency 'rake'
Expand Down
2 changes: 2 additions & 0 deletions lib/draper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
require 'active_support/core_ext/hash/reverse_merge'
require 'active_support/core_ext/name_error'

require 'ruby2_keywords'

require 'draper/version'
require 'draper/configuration'
require 'draper/view_helpers'
Expand Down
4 changes: 2 additions & 2 deletions lib/draper/automatic_delegation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module AutomaticDelegation
# method calls to `object` as well. Calling `super` will first try to call the method on
# the parent decorator class. If no method exists on the parent class, it will then try
# to call the method on the `object`.
def method_missing(method, *args, &block)
ruby2_keywords def method_missing(method, *args, &block)
return super unless delegatable?(method)

object.send(method, *args, &block)
Expand All @@ -27,7 +27,7 @@ def delegatable?(method)

module ClassMethods
# Proxies missing class methods to the source class.
def method_missing(method, *args, &block)
ruby2_keywords def method_missing(method, *args, &block)
return super unless delegatable?(method)

object_class.send(method, *args, &block)
Expand Down
3 changes: 2 additions & 1 deletion lib/draper/helper_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(view_context)
end

# Sends helper methods to the view context.
def method_missing(method, *args, &block)
ruby2_keywords def method_missing(method, *args, &block)
self.class.define_proxy method
send(method, *args, &block)
end
Expand All @@ -31,6 +31,7 @@ def self.define_proxy(name)
define_method name do |*args, &block|
view_context.send(name, *args, &block)
end
ruby2_keywords name
end
end
end
2 changes: 1 addition & 1 deletion lib/draper/lazy_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Draper
# bazillion methods.
module LazyHelpers
# Sends missing methods to the {HelperProxy}.
def method_missing(method, *args, &block)
ruby2_keywords def method_missing(method, *args, &block)
helpers.send(method, *args, &block)
rescue NoMethodError
super
Expand Down
2 changes: 1 addition & 1 deletion lib/draper/query_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Draper
module QueryMethods
# Proxies missing query methods to the source class if the strategy allows.
def method_missing(method, *args, &block)
ruby2_keywords def method_missing(method, *args, &block)
return super unless strategy.allowed? method

object.send(method, *args, &block).decorate(with: decorator_class, context: context)
Expand Down
2 changes: 1 addition & 1 deletion lib/draper/view_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def helpers

# Alias for `helpers.localize`, since localize is something that's used
# quite often. Further aliased to `l` for convenience.
def localize(*args)
ruby2_keywords def localize(*args)
helpers.localize(*args)
end

Expand Down

0 comments on commit 9cb42f6

Please sign in to comment.