lib/aasm/base.rb in aasm-5.2.0 vs lib/aasm/base.rb in aasm-5.3.0
- old
+ new
@@ -221,10 +221,23 @@
unless AASM::Configuration.hide_warnings
@state_machine.config.logger.warn "#{klass.name}: overriding method '#{method_name}'!"
end
end
- klass.send(:define_method, method_name, method_definition)
+ klass.send(:define_method, method_name, method_definition).tap do |sym|
+ apply_ruby2_keyword(klass, sym)
+ end
+ end
+
+ def apply_ruby2_keyword(klass, sym)
+ if RUBY_VERSION >= '2.7.1'
+ if klass.instance_method(sym).parameters.find { |type, _| type.to_s.start_with?('rest') }
+ # If there is a place where you are receiving in *args, do ruby2_keywords.
+ klass.module_eval do
+ ruby2_keywords sym
+ end
+ end
+ end
end
def namespace?
!!@state_machine.config.namespace
end