public
Created

  • Download Gist
call_flow.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11
class CallFlow < ActiveRecord::Base
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
geo_option.rb
Ruby
1 2 3 4 5 6 7 8 9 10
class GeoOption < ActiveRecord::Base
belongs_to :route_by_geography
belongs_to :target_routable, :polymorphic => true
geocoded_by :full_street_address
reverse_geocoded_by :latitude, :longitude
def target_route=(params)
self.target_routable = params[:kind].constantize.new(params.reject {|k,v| k == "kind"})
end
end
ivr_option.rb
Ruby
1 2 3 4 5 6 7 8
class IvrOption < ActiveRecord::Base
belongs_to :route_by_ivr
belongs_to :target_routable, :polymorphic => true
 
def target_route=(params)
self.target_routable = params[:kind].constantize.new(params.reject {|k,v| k == "kind"})
end
end
message_option.rb
Ruby
1 2 3 4 5 6 7 8
class MessageOption < ActiveRecord::Base
belongs_to :route_by_message
belongs_to :target_routable, :polymorphic => true
 
def target_route=(params)
self.target_routable = params[:kind].constantize.new(params.reject {|k,v| k == "kind"})
end
end
route_by_geography.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13
class RouteByGeography < ActiveRecord::Base
has_many :call_flows, :as => :routable
has_many :geo_options
accepts_nested_attributes_for :geo_options
 
def options
self.geo_options
end
 
def description
options.map {|o| "\nGEO: If value is #{o.value}, target DID #{o.target_did || 'n/a'}, target route: #{o.target_routable.try(:description) || 'n/a'}" }.join("\n")
end
end
route_by_ivr.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
class RouteByIvr < ActiveRecord::Base
has_many :call_flows, :as => :routable
has_many :ivr_options
accepts_nested_attributes_for :ivr_options
 
def options
self.ivr_options
end
 
def description
options.map {
|o| "\nIVR: If value is #{o.value},
target DID #{o.target_did || 'n/a'},
target route: #{o.target_routable.try(:description) || 'n/a'}"
}.join("\n")
end
end
route_by_message.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14
class RouteByMessage < ActiveRecord::Base
has_many :call_flows, :as => :routable
has_many :message_options, :dependent => :destroy
accepts_nested_attributes_for :message_options
 
def options
self.message_options
end
 
def description
options.map {|o| "\nMESSAGE: Play message '#{o.message}', target DID #{o.target_did || 'n/a'}, target route: #{o.target_routable.try(:description) || 'n/a'}" }.join("\n")
end
end
schema.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
 
ActiveRecord::Schema.define(:version => 20120127222330) do
 
create_table "call_flows", :force => true do |t|
t.string "dnis"
t.string "default_ringto_did"
t.integer "zoho_id"
t.integer "ouid"
t.string "routable_type"
t.integer "routable_id"
t.integer "repeat_greeting_on_invalid", :default => 0
t.string "caller_to_sms"
t.string "email_to_notify"
t.string "play_disclaimer", :default => "before"
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "is_outbound"
t.string "country_code", :limit => 10, :default => "1"
end
 
create_table "geo_options", :force => true do |t|
t.integer "route_by_geography_id"
t.integer "organizational_unit_id"
t.float "latitude"
t.float "longitude"
t.string "target_did"
t.string "target_routable_type"
t.integer "target_routable_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "address"
end
 
create_table "ivr_options", :force => true do |t|
t.integer "ouid"
t.integer "route_by_ivr_id"
t.string "value"
t.string "target_did"
t.string "target_routable_type"
t.integer "target_routable_id"
t.datetime "created_at"
t.datetime "updated_at"
end
 
create_table "message_options", :force => true do |t|
t.integer "route_by_message_id"
t.string "message"
t.string "target_did"
t.string "target_routable_type"
t.integer "target_routable_id"
t.datetime "created_at"
t.datetime "updated_at"
end
 
create_table "route_by_geographies", :force => true do |t|
t.integer "radius", :default => 25
t.integer "play_branding", :default => 1
t.datetime "created_at"
t.datetime "updated_at"
end
 
create_table "route_by_ivrs", :force => true do |t|
t.integer "repeat_greeting"
t.datetime "created_at"
t.datetime "updated_at"
end
 
create_table "route_by_messages", :force => true do |t|
t.datetime "created_at"
t.datetime "updated_at"
end
 
create_table "route_by_outbounds", :force => true do |t|
t.integer "pin"
t.string "callerid", :limit => 25
t.integer "play_disclaimer"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "play_prompt"
end
 
create_table "route_by_schedules", :force => true do |t|
t.string "timezone"
t.datetime "created_at"
t.datetime "updated_at"
end
 
create_table "schedule_options", :force => true do |t|
t.integer "route_by_schedule_id"
t.integer "day"
t.string "from_time"
t.string "to_time"
t.string "target_did"
t.string "target_routable_type"
t.integer "target_routable_id"
t.datetime "created_at"
t.datetime "updated_at"
end
 
 
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.