Skip to content

Instantly share code, notes, and snippets.

@svs
Created December 30, 2012 15:22
Show Gist options
  • Save svs/4413279 to your computer and use it in GitHub Desktop.
Save svs/4413279 to your computer and use it in GitHub Desktop.
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