-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Constants dynamically created. Some tests in CampaignManagement
- Loading branch information
Showing
8 changed files
with
87 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,74 @@ | ||
# -*- encoding : utf-8 -*- | ||
|
||
module BingAdsApi | ||
|
||
# Public : Utility class for TimeZones values | ||
# | ||
# Example | ||
# BingAdsApi::TimeZone.SANTIAGO | ||
# # => 'Santiago' | ||
# | ||
# Author [email protected] | ||
module TimeZone | ||
|
||
module CommonConstants | ||
class <<self | ||
BingAdsApi::Config.instance.common_constants.each do |key, value| | ||
|
||
define_method("#{key.upcase}") do |constant=nil| | ||
value[constant] if constant | ||
value | ||
BingAdsApi::Config.instance.common_constants['time_zones'].each do |key, value| | ||
TimeZone.const_set(key.upcase, value) | ||
end | ||
|
||
end | ||
|
||
# Public : Utility class for AdLanguages values | ||
# | ||
# Example | ||
# BingAdsApi::AdLanguages.SPANISH | ||
# # => 'Spanish' | ||
# BingAdsApi::AdLanguages.SPANISH_CODE | ||
# # => 'ES' | ||
# | ||
# Author [email protected] | ||
module AdLanguage | ||
|
||
BingAdsApi::Config.instance.common_constants['ad_languages'].each do |key, value| | ||
if key == 'codes' | ||
value.each do |code_key, code_value| | ||
AdLanguage.const_set("#{code_key.upcase}_CODE", code_value) | ||
end | ||
|
||
else | ||
AdLanguage.const_set(key.upcase, value) | ||
end | ||
end | ||
end | ||
|
||
end | ||
|
||
|
||
module CampaignManagementConstants | ||
class <<self | ||
BingAdsApi::Config.instance.campaign_management_constants.each do |key, value| | ||
|
||
define_method("#{key.upcase}") do |constant=nil| | ||
value[constant.to_s] if constant | ||
value | ||
end | ||
|
||
## Dynamic classes for campaign management constants | ||
BingAdsApi::Config.instance.campaign_management_constants.each do |const_key, const_value| | ||
|
||
const_module = Module.new do | ||
# Dynamically create Constants classes for each value found | ||
const_value.each do |key, value| | ||
self.const_set(key.upcase, value) | ||
end | ||
end | ||
|
||
end | ||
BingAdsApi.const_set(const_key.classify, const_module) | ||
|
||
end | ||
|
||
|
||
## Dynamic classes for reporting constants | ||
BingAdsApi::Config.instance.reporting_constants.each do |const_key, const_value| | ||
|
||
const_class = Class.new(Object) do | ||
# Dynamically create Constants classes for each value found | ||
const_value.each do |key, value| | ||
self.const_set(key.upcase, value) | ||
end | ||
|
||
end | ||
BingAdsApi.const_set(const_key.classify, const_class) | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters