Last active
October 24, 2018 01:10
-
-
Save kevinnio/ec0e0b9ea4ad26988f63f27dbaf878a4 to your computer and use it in GitHub Desktop.
Spree/Solidus Module Decorator pattern
This file contains hidden or 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
require 'active_support/concern' | |
module MyNamespace::SpreeDecorator | |
extend ActiveSupport::Concern | |
included do | |
# Call base class methods here! | |
some_class_method :foo | |
some_class_method_with_block do | |
another_class_method :bar | |
end | |
end | |
def overridden_method | |
# Overrides method | |
end | |
def overridden_method_calling_original_one | |
super # this is available using this decorator approach | |
# New code | |
end | |
def totally_new_method | |
# Just a plain old method | |
end | |
end | |
Spree::ClassToBeDecorated.include MyNamespace::SpreeDecorator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment