Class: Campaign
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Campaign
- Defined in:
- app/models/entities/campaign.rb
Overview
Schema Information
Table name: campaigns
id :integer not null, primary key
user_id :integer
assigned_to :integer
name :string(64) default(""), not null
access :string(8) default("Public")
status :string(64)
budget :decimal(12, 2)
target_leads :integer
target_conversion :float
target_revenue :decimal(12, 2)
leads_count :integer
opportunities_count :integer
revenue :decimal(12, 2)
starts_on :date
ends_on :date
objectives :text
deleted_at :datetime
created_at :datetime
updated_at :datetime
background_info :string(255)
Class Method Summary collapse
- .outline ⇒ Object
-
.per_page ⇒ Object
Default values provided through class methods.
Instance Method Summary collapse
-
#attach!(attachment) ⇒ Object
Attach given attachment to the campaign if it hasn’t been attached already.
-
#discard!(attachment) ⇒ Object
Discard given attachment from the campaign.
Class Method Details
.outline ⇒ Object
81 |
# File 'app/models/entities/campaign.rb', line 81 def self.outline ; "long" ; end |
.per_page ⇒ Object
Default values provided through class methods.
80 |
# File 'app/models/entities/campaign.rb', line 80 def self.per_page ; 20 ; end |
Instance Method Details
#attach!(attachment) ⇒ Object
Attach given attachment to the campaign if it hasn’t been attached already.
85 86 87 88 89 90 91 92 93 94 95 |
# File 'app/models/entities/campaign.rb', line 85 def attach!() unless self.send("#{.class.name.downcase}_ids").include?(.id) if .is_a?(Task) self.send(.class.name.tableize) << else # Leads, Opportunities .update_attribute(:campaign, self) .send("increment_#{.class.name.tableize}_count") [ ] end end end |
#discard!(attachment) ⇒ Object
Discard given attachment from the campaign.
99 100 101 102 103 104 105 106 |
# File 'app/models/entities/campaign.rb', line 99 def discard!() if .is_a?(Task) .update_attribute(:asset, nil) else # Leads, Opportunities .send("decrement_#{.class.name.tableize}_count") .update_attribute(:campaign, nil) end end |