Skip to content

Instantly share code, notes, and snippets.

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