Class: OpenX::Services::Channel

Inherits:
Base
  • Object
show all
Defined in:
lib/openx/services/channel.rb

Instance Method Summary collapse

Methods inherited from Base

#<=>, establish_connection, has_one, #new_record?, openx_accessor, remote, with_connection

Methods included from Persistance::ClassMethods

#create!, #destroy, #find

Methods included from Persistance::InstanceMethods

#destroy, #save!

Constructor Details

#initialize(params = {}) ⇒ Channel

Returns a new instance of Channel.



20
21
22
23
24
# File 'lib/openx/services/channel.rb', line 20

def initialize(params = {})
  raise "need publisher" unless params[:publisher_id] || params[:publisher]
  params[:publisher_id] ||= params[:publisher].id
  super(params)
end

Instance Method Details

#targetingObject

Retrieves targeting from channel



27
28
29
30
31
32
# File 'lib/openx/services/channel.rb', line 27

def targeting
  raise "Channel must be saved" if new_record?
  remote.call("ox.getChannelTargeting", self.id).map do |line|
    TargetingRule.instantiate(line)
  end
end

#targeting=(rules) ⇒ Object

Applied targeting to channel. See OpenX::TargetingRules for details



35
36
37
38
# File 'lib/openx/services/channel.rb', line 35

def targeting=(rules)
  raise "Channel must be saved" if new_record?
  remote.call("ox.setChannelTargeting",  self.id, rules)
end