Skip to content

Commit

Permalink
Move decorators to patches/, configure Flickwerk
Browse files Browse the repository at this point in the history
This stops us from loading line item, order, adjustment, shipment,
shipping rate, and the order recalculator on app startup.
  • Loading branch information
mamhoff committed Jan 3, 2025
1 parent 3764d58 commit d1f57b6
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module SolidusPromotions
module AdjustmentDecorator
module AdjustmentPatch
def self.prepended(base)
base.scope :solidus_promotion, -> { where(source_type: "SolidusPromotions::Benefit") }
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module SolidusPromotions
module LineItemDecorator
module LineItemPatch
def self.prepended(base)
base.attr_accessor :quantity_setter
base.belongs_to :managed_by_order_benefit, class_name: "SolidusPromotions::Benefit", optional: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module SolidusPromotions
module OrderDecorator
module OrderPatch
module ClassMethods
def allowed_ransackable_associations
super + ["solidus_promotions", "solidus_order_promotions"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module SolidusPromotions
module OrderRecalculatorDecorator
module OrderRecalculatorPatch
# This is only needed for stores upgrading from the legacy promotion system.
# Once we've removed support for the legacy promotion system, we can remove this.
def recalculate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module SolidusPromotions
module ShipmentDecorator
module ShipmentPatch
Spree::Shipment.prepend SolidusPromotions::DiscountableAmount

def reset_current_discounts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module SolidusPromotions
module ShippingRateDecorator
module ShippingRatePatch
def self.prepended(base)
base.class_eval do
has_many :discounts,
Expand Down
3 changes: 3 additions & 0 deletions promotions/lib/solidus_promotions/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

require "solidus_core"
require "solidus_support"
require "flickwerk"

module SolidusPromotions
class Engine < Rails::Engine
include SolidusSupport::EngineExtensions
include Flickwerk
Flickwerk.aliases["Spree::Config.order_recalculator_class"] = Spree::Config.order_recalculator_class_name

isolate_namespace ::SolidusPromotions

Expand Down

0 comments on commit d1f57b6

Please sign in to comment.