Created
November 19, 2014 17:09
-
-
Save jphenow/cfb838d9e9550bbc749a to your computer and use it in GitHub Desktop.
Specific Purpose Model Decoration
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
class ResourcePurchase::ResourceDecorators::Base < SimpleDelegator | |
def anew | |
end | |
def renew | |
end | |
end | |
# You could write a router if you want to make this follow | |
# something of a Factory pattern or do something like | |
class MembershipEvent | |
# This could be abstracted into the Purchasable to | |
# _try_ to find a related class | |
def resource_purchase_class | |
ResourcePurchase::ResourceDecorators::MembershipEvent | |
end | |
# Can also be abstracted | |
def resource_purchase_instance | |
resource_purchase_class.new(self) | |
end | |
end | |
resource_purchase.item.resource_purchase_instance.anew |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment