Created
December 30, 2012 15:45
-
-
Save svs/4413397 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 Quotation | |
# ...snip... | |
# methods to be forwarded to the status policy class | |
def self.status_policy_methods | |
[:unconfirmed?, :expirable?, :approvable?, :rejectable?, :poolable?, :on_holdable?, :payable?, :callbackable?, :sendable?] | |
end | |
# methods to be forwarded to workflow class | |
def self.workflow_methods | |
QuotationWorkflow.instance_methods(false) - [:method_missing] + [:has_events?, :has_only_events?] | |
end | |
# the class to be used for the status policy | |
def status_policy(policy_class = QuotationStatusPolicy) | |
policy_class.new(self) | |
end | |
def workflow(workflow_class = QuotationWorkflow) | |
workflow_class.new(self) | |
end | |
extend Forwardable | |
def_delegators :status_policy, *(Quotation.status_policy_methods) | |
def_delegators :workflow, *(Quotation.workflow_methods) | |
# ...snip ... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment