Created
March 9, 2012 03:28
-
-
Save libryder/2004854 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 CallFlow < ActiveRecord::Base | |
| establish_connection "callengine_#{Rails.env}" | |
| belongs_to :routable, :polymorphic => true | |
| def dialplan | |
| puts self.routable.description.squeeze("\n").strip | |
| end | |
| def target_route=(params) | |
| self.routable = params[:kind].constantize.new(params.reject {|k,v| k == "kind"}) | |
| end | |
| end |
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
| case params[:route_type] | |
| when "simple" | |
| # Setup the nested attributes to pass to the models and create a callflow | |
| # validate_hash is a flat hash of attributes meant for the CallFlow model | |
| @nested_attributes = validate_hash[:criteria].merge({ | |
| 'target_route' => { | |
| 'kind' => 'RouteByMessage', | |
| 'message_options_attributes' => { | |
| 'message' => message, | |
| 'target_did' => ringto | |
| } | |
| } | |
| }) | |
| call_flow = CallFlow.create(@nested_attributes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment