Skip to content

Instantly share code, notes, and snippets.

@libryder
Created January 30, 2012 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save libryder/1701475 to your computer and use it in GitHub Desktop.
Save libryder/1701475 to your computer and use it in GitHub Desktop.
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
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
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
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
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
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
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
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment