-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from mamhoff/rename-decorator-constants
Use our namespace for decorator constant
- Loading branch information
Showing
8 changed files
with
77 additions
and
69 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
app/decorators/models/alchemy/solidus/spree_product_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module Alchemy | ||
module Solidus | ||
module SpreeProductDecorator | ||
def self.prepended(base) | ||
base.include Alchemy::Solidus::TouchAlchemyIngredients | ||
base.has_many :alchemy_ingredients, class_name: "Alchemy::Ingredients::SpreeProduct", as: :related_object, dependent: :nullify | ||
end | ||
|
||
private | ||
|
||
# Overwritten Solidus' default behavior | ||
# | ||
# The Solidus implementation did not trigger `touch` on taxons, but | ||
# updated the `updated_at` timestamp in an `update_all`. | ||
# | ||
# Since we want to invalidate ingredient spree taxons cache as well | ||
# we need to use `touch` here and use the `after_touch` callback of | ||
# Spree::Taxon | ||
# | ||
def touch_taxons | ||
taxons.each(&:touch) | ||
end | ||
|
||
::Spree::Product.prepend self | ||
end | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
app/decorators/models/alchemy/solidus/spree_taxon_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Alchemy | ||
module Solidus | ||
module SpreeTaxonDecorator | ||
def self.prepended(base) | ||
base.include Alchemy::Solidus::TouchAlchemyIngredients | ||
base.has_many :alchemy_ingredients, class_name: "Alchemy::Ingredients::SpreeTaxon", as: :related_object, dependent: :nullify | ||
end | ||
|
||
::Spree::Taxon.prepend self | ||
end | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
app/decorators/models/alchemy/solidus/spree_variant_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Alchemy | ||
module Solidus | ||
module SpreeVariantDecorator | ||
def self.prepended(base) | ||
base.include Alchemy::Solidus::TouchAlchemyIngredients | ||
base.has_many :alchemy_ingredients, class_name: "Alchemy::Ingredients::SpreeVariant", as: :related_object, dependent: :nullify | ||
end | ||
|
||
::Spree::Variant.prepend self | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Alchemy | ||
module Solidus | ||
module TouchAlchemyIngredients | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
after_update :touch_alchemy_ingredients | ||
after_touch :touch_alchemy_ingredients | ||
end | ||
|
||
private | ||
|
||
def touch_alchemy_ingredients | ||
alchemy_ingredients.each(&:touch) | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.