lib/epom_rails/config.rb in epom_rails-0.4.9 vs lib/epom_rails/config.rb in epom_rails-1.0.0

- old
+ new

@@ -15,11 +15,11 @@ end # need a Class for 3.0 class Configuration #:nodoc: include ActiveSupport::Configurable - config_accessor :offline + config_accessor :offline, :advertiser, :campaign, :banner, :site, :zone, :placement def param_name config.param_name.respond_to?(:call) ? config.param_name.call : config.param_name end @@ -30,7 +30,35 @@ end # this is ugly. why can't we pass the default value to config_accessor...? EpomRails.configure do |config| config.offline = false + + config.advertiser = {} + config.advertiser[:fields] = {epom_id: 'id', name: 'name', contact_name: 'contactName', contact_email: 'contactEmail', description: 'description'} + config.advertiser[:has_many] = [{:name => 'campaigns', :epom_element => 'Campaign', :model => 'Campaign'}] + + config.campaign = {} + config.campaign[:fields] = {epom_id: 'id', name: 'name', description: 'description', advertiser_id: 'advertiserId', weight: 'weight'} + config.campaign[:has_many] = [{:name => 'banners', :epom_element => 'Banner', :model => 'Banner'}] + config.campaign[:belongs_to] = [{:name => 'advertiser', :epom_element => 'Advertiser', :model => 'Advertiser'}] + + config.banner = {} + config.banner[:fields] = {epom_id: 'id', placement_type: 'placementType', campaign_id: 'campaignId', weight: 'weight', image_banner_link: 'imageBannerLink', url: 'url', name: 'name', banner_type: 'bannerType', ad_unit_id: 'adUnitId', ad_unit_width: 'adUnitWidth', ad_unit_height: 'adUnitHeight'} + config.banner[:has_many] = [{:name => 'placements', :epom_element => 'Placement', :model => 'Placement'}] + config.banner[:belongs_to] = [{:name => 'campaign', :epom_element => 'Campaign', :model => 'Campaign'}] + + config.site = {} + config.site[:fields] = {epom_id: 'id', name: 'name', url: 'url', description: 'description', email: 'email', category_id: 'categoryId'} + config.site[:has_many] = [{:name => 'zones', :epom_element => 'Zone', :model => 'Zone'}] + + config.zone = {} + config.zone[:fields] = {epom_id: 'id', name: 'name', description: 'description', site_id: 'siteId'} + config.zone[:has_many] = [{:name => 'placements', :epom_element => 'Placement', :model => 'Placement'}] + config.zone[:belongs_to] = [{:name => 'site', :epom_element => 'Site', :model => 'Site'}] + + config.placement = {} + config.placement[:fields] = {epom_id: 'id', zone_id: 'zoneId', placement_type: 'type', name: 'name', ad_unit_id: 'adUnitId', size_height: 'size.height', size_width: 'size.width'} + config.placement[:has_many] = [{:name => 'banners', :epom_element => 'Banner', :model => 'Banner'}] + config.placement[:belongs_to] = [{:name => 'zone', :epom_element => 'Zone', :model => 'Zone'}] end end