Module: EpomRails

Defined in:
lib/epom_rails.rb,
lib/epom_rails/config.rb,
lib/epom_rails/version.rb,
lib/generators/epom_rails/config/config_generator.rb

Defined Under Namespace

Classes: ConfigGenerator, Configuration

Constant Summary collapse

VERSION =
"1.4.4"

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/epom_rails.rb', line 14

def method_missing(method_name, *args)
	if not EpomRails.config.offline and epom_class.respond_to?(method_name)
		# this permits to use:
		# Campaign.get_campaign({:campaignId => campaign.send(epom_field('id'))}, {})
		epom_class.send(method_name, *args)
	else
		super
	end
end

Class Method Details

.configObject

Global settings for EpomRails



13
14
15
# File 'lib/epom_rails/config.rb', line 13

def self.config
  @config
end

.configure {|@config ||= EpomRails::Configuration.new| ... } ⇒ Object

Configures global settings for EpomRails

EpomRails.configure do |config|
  config.offline = false
end

Yields:



8
9
10
# File 'lib/epom_rails/config.rb', line 8

def self.configure(&block)
  yield @config ||= EpomRails::Configuration.new
end

Instance Method Details

#epom_classObject



24
25
26
27
28
29
30
31
32
# File 'lib/epom_rails.rb', line 24

def epom_class
	return Epom::Advertiser if EpomRails.config.advertiser[:model] == self
	return Epom::Campaign if EpomRails.config.campaign[:model] == self
	return Epom::Banner if EpomRails.config.banner[:model] == self
	return Epom::Site if EpomRails.config.site[:model] == self
	return Epom::Zone if EpomRails.config.zone[:model] == self
	return Epom::Placement if EpomRails.config.placement[:model] == self
	return Epom::Analytic if EpomRails.config.analytic[:model] == self
end