Created
December 30, 2012 15:22
-
-
Save svs/4413279 to your computer and use it in GitHub Desktop.
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 QuotationStatusPolicy | |
def initialize(quotation) | |
@quotation = quotation | |
end | |
# STATUSES | |
def unconfirmed? | |
[:mildly_interested, :negotiating].include?(quality) | |
end | |
def expirable? | |
true if self.start_date <= Date.today | |
end | |
def sendable? | |
(approved? || sent?) && !intended_trip.user.email.blank? && !expirable? | |
end | |
def approvable? | |
set_end_date | |
(start_date && end_date) && !sent? && !unconfirmed? && !approved? && !expirable? | |
end | |
def rejectable? | |
!sent? && !rejected? && !expirable? | |
end | |
def poolable? | |
(approved? || sent? || paid?) && !expirable? | |
end | |
def on_holdable? | |
(!sent? && !unconfirmed?) && !expirable? | |
end | |
def payable? | |
true unless (approvable? || expirable?) | |
end | |
def callbackable? | |
true unless approved? || sent? || rejected? || paid? | |
end | |
def method_missing(name, *args) | |
@quotation.send(name, *args) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment