Created
September 19, 2012 19:57
-
-
Save rmascarenhas/3751867 to your computer and use it in GitHub Desktop.
delivery strategy
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
class TagSubscription < ActiveRecord::Base | |
belongs_to :delivery_strategy | |
end | |
class DeliveryStrategy < ActiveRecord::Base | |
# Attributes: | |
# type: can be 'real_time', 'daily' or 'weekly' | |
# day: contain the day of the week | |
# time: the time of the day (morning, afternoon, night) | |
# | |
has_many :tag_subscriptions | |
end | |
# Find immediate deliveries | |
DeliveryStrategy.where(:type => :real_time) | |
# Find daily deliveries of the morning | |
DeliveryStrategy.where(:type => :daily, :time => :morning) | |
# Weekly subscriptions to be delivered every Tuesday night | |
DeliveryStrategy.where(:type => :weekly, :day => :tuesday, :time => :night) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm ok with it, I was thinking if
DeliveryStrategy
needed to be an AR, but I agree with it...If for some reason we get more types of subscriptions, we can easily port to a polymorphic version..
👍