Sha256: b154da9888591111157e69b0201c60be7bb17956cd30235cff204255df74957a
Contents?: true
Size: 911 Bytes
Versions: 6
Compression:
Stored size: 911 Bytes
Contents
class ActiveRecord::Base def self.acts_as_analytic(params = {}) EpomRails.config.analytic[:model] = self extend EpomRails override_config(Epom::Analytic, params) define_analytic_from_epom end private def self.define_analytic_from_epom self.class_eval do def self.analytic_from_epom(params) default = { :format => 'JSON', :displayIds => true, :groupBy => 'ADVERTISER,CAMPAIGN,BANNER,SITE,ZONE,PLACEMENT,CHANNEL,COUNTRY', :groupRange => 'DAY', } analytics = JSON.parse(Epom::Analytic.analytics(default.merge(params))) fields = get_config[:fields] analytics.map do |analytic| data = {} fields.map {|key, value| data[key] = analytic[value]} data[:date] = Date.parse(data[:date]) if data[:date].is_a?(String) self.new(data) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems