Created
November 29, 2012 20:03
-
-
Save wacko/4171519 to your computer and use it in GitHub Desktop.
Parte de la lógica que hay que sacar de OfferPage a un Builder
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
offer_page = OfferPageBuilder.new(account).build |
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 OfferPageBuilder | |
def initialize(account) | |
@account = account | |
end | |
def build | |
page = OffersPage.new { | |
name: "Special Offers", | |
heading: "Special Offers on Dental Services in #{@account.geo_keyword}, #{@account.state}", | |
intro_paragraph: "" | |
} | |
add_starting_records page | |
page | |
end | |
#Adds the initial set of offers to an offers page | |
def add_starting_records page | |
date = (Time.current + 90.days).strftime("%m/%d/%y") | |
Offer.create { | |
description: "Save 5% on your next teeth cleaning", | |
fine_print: "Offer expires #{date}. Limit one per person.", | |
intro: "Bring in this coupon to save on your next cleaning.", | |
page: page | |
} | |
Offer.create { | |
description: "Refer a friend and get 5% off your next exam", | |
fine_print: "Offer expires #{date}. Limit one per person.", | |
intro: "We appreciate your referrals. We'll also give you a free filling for any friends you refer. Make sure they let us know who referred them when they come in.", | |
page: page | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment