Skip to content

Issues with inflection AU #410

Description

@gamecreature

In pull request #332, an acronym inflection is added to support the incorrect class name Spree::GateWay::SecurePayAU (app/models/spree/gateway/secure_pay_au.rb).

Because Zeitwork doesn't like the naming scheme of SecurePayAU.
This inflection causes unexpected behavior when using .titleize on a string.

Due to this change the the brand WALDLAUFER is titleized Waldl AU Fer.
This inflection also causes Zeitwerk issues on every AU classname.

If the capitalized AU is important, (for backwards compatibility).
Isn't it a better solution to just add alias for this class.

Solution

I think best solution is to remove the inflection and rename the class from SecurePayAU to SecurePayAu. Of course this can/will be an issue with existing installations.

Backwards compatibility Solution

Another solution is the following

Remove the inflection: config/initializers/inflections.rb

# DELETE: inflect.acronym 'AU'

Rename the class and add an alias for the class to app/models/spree/gateway/secure_pay_au.rb, so it follows the Zeitwerk naming

module Spree
  class Gateway::SecurePayAu < Gateway
    #... 
  end
  Gateway::SecurePayAU = Gateway::SecurePayAu
end

In the lib/spree_gateway/engine.rb register both classes OR use the following construct to load the legacy classname.

Spree::Gateway::SecurePayAu 
app.config.spree.payment_methods << Spree::Gateway::SecurePayAU

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions