Class: Landable::Traffic::Attribution
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Landable::Traffic::Attribution
- Includes:
- Landable::TableName
- Defined in:
- app/models/landable/traffic/attribution.rb
Constant Summary collapse
- KEYS =
%w[ad_type ad_group bid_match_type campaign content creative device_type experiment keyword match_type medium network placement position search_term source target]
Class Method Summary collapse
Class Method Details
.digest(parameters) ⇒ Object
33 34 35 |
# File 'app/models/landable/traffic/attribution.rb', line 33 def digest(parameters) Digest::SHA2.base64digest transform(parameters).values.join end |
.lookup(parameters) ⇒ Object
29 30 31 |
# File 'app/models/landable/traffic/attribution.rb', line 29 def lookup(parameters) where(transform(parameters)).first_or_create end |
.transform(parameters) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/models/landable/traffic/attribution.rb', line 17 def transform(parameters) hash = parameters.slice(*KEYS) filter = {} hash.each do |k, v| filter[k.foreign_key] = "Landable::Traffic::#{k.classify}".constantize[v] end filter end |