Class: Ronin::Campaign
- Inherits:
-
Object
- Object
- Ronin::Campaign
- Includes:
- DataMapper::Timestamps, Model, Model::HasDescription, Model::HasUniqueName
- Defined in:
- lib/ronin/campaign.rb
Overview
Represents a grouping of targeted Addresses.
Class Method Summary collapse
-
.targeting(addr) ⇒ Array<Campaign>
Searches for all campaigns targeting an Address.
-
.targeting_orgs(names) ⇒ Array<Campaign>
Searches for all campaigns targeting an Organization.
Instance Method Summary collapse
-
#target!(addr) ⇒ Target
Adds an address to the campaign.
-
#targets?(addr) ⇒ Boolean
Determines if an address is targeted by the campaign.
Methods included from Model::HasDescription
Methods included from Model::HasUniqueName
Methods included from Model
Class Method Details
.targeting(addr) ⇒ Array<Campaign>
Searches for all campaigns targeting an Address.
66 67 68 |
# File 'lib/ronin/campaign.rb', line 66 def self.targeting(addr) all('addresses.address' => addr) end |
.targeting_orgs(names) ⇒ Array<Campaign>
Searches for all campaigns targeting an Organization.
83 84 85 |
# File 'lib/ronin/campaign.rb', line 83 def self.targeting_orgs(names) all('organizations.name' => names) end |
Instance Method Details
#target!(addr) ⇒ Target
Adds an address to the campaign.
120 121 122 123 124 125 126 |
# File 'lib/ronin/campaign.rb', line 120 def target!(addr) unless (address = Address.first(:address => addr)) raise("unknown address #{addr.dump}") end return Target.first_or_create(:campaign => self, :address => address) end |
#targets?(addr) ⇒ Boolean
Determines if an address is targeted by the campaign.
100 101 102 |
# File 'lib/ronin/campaign.rb', line 100 def targets?(addr) self.addresses.include?(address) end |