Skip to content

Instantly share code, notes, and snippets.

@wacko
Created November 29, 2012 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wacko/4171519 to your computer and use it in GitHub Desktop.
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
offer_page = OfferPageBuilder.new(account).build
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