Created
October 7, 2014 07:57
-
-
Save igor-alexandrov/19d6ca0a28f2059117dd to your computer and use it in GitHub Desktop.
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
@purchased_at = Date.civil(params[:purchased_at]["(1i)"].to_i, | |
params[:purchased_at]["(2i)"].to_i, | |
params[:purchased_at]["(3i)"].to_i) | |
@code = Partner::Code.lookup("Vendor", params[:code]) || build_vendor_code | |
@not_redeem = nil | |
@error_text = nil | |
@to_late = nil | |
if @code.nil? | |
@not_redeem = true | |
@error_text = I18n.t("fc.check_all_fields") | |
elsif @purchased_at >= Date.parse("01/07/2014") | |
@to_late = true | |
@error_text = I18n.t('fc.to_late') | |
elsif @code.new_record? | |
if @code.save | |
@error_text = I18n.t("fc.receipt_sent") | |
@not_redeem = true | |
else | |
@not_redeem = true | |
@error_text = I18n.t("fc.receipt_is_not_sent") | |
end | |
elsif @code.not_confirmed? | |
@not_redeem = true | |
@error_text = I18n.t("fc.receipt_already_sent") | |
elsif @code.confirmed? | |
order = Paysteps::Order.new | |
order.payable = @code.payable | |
order.payer = current_user | |
@error_text = I18n.t("fc.already_bought") unless @code.payable.can_be_bought_with?(order) | |
elsif @code.redeemed? | |
@not_redeem = true | |
@error_text = I18n.t("fc.already_redeemed") | |
end |
как-то маловато переменных экземпляра класса :)
Игорь, покажи потом как зарефакторил.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Во, отличный пример для рефакторинга. Прям как у Sandi был на конфе)