Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix publishing events responding to #to_hash on Ruby 2.7
When a method accepts both splatted positional & keyword parameters and a single argument responding to `#to_hash` is given, the argument is coerced to hash and assigned to the keyword arguments. E.g.: class Hashable def to_hash { im: :a_hash } end end def method_with_splat_on_the_positional_argument(*args, **kwargs) # method_with_splat_on_the_positional_argument(Hashable.new) puts args.inspect # => [] puts kwargs.inspect # => {:im=>:a_hash} end However, def method_without_splat_on_the_positional_argument(args, **kwargs) # method_without_splat_on_the_positional_argument(Hashable.new) puts args.inspect # => #<Hashable:0x000055cfe8b072b0> puts kwargs.inspect # => {} end We fix the problem on the Spree::Bus override by being explicit about the expected parameters. References solidusio/solidus_stripe#157 (comment) (cherry picked from commit d69f8d7)
- Loading branch information