Class: Yandex::Direct::Base

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, ActiveModel::Serialization, ActiveModel::Validations
Defined in:
lib/yandex/direct/base.rb

Direct Known Subclasses

Campaign

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create(attributes) ⇒ Object



13
14
15
16
# File 'lib/yandex/direct/base.rb', line 13

def create(attributes)
  object = self.new(attributes)
  object.save
end

.initialize(*args) ⇒ Object



10
11
12
# File 'lib/yandex/direct/base.rb', line 10

def initialize(*args)
  super
end

.pathObject



19
20
21
# File 'lib/yandex/direct/base.rb', line 19

def path
  self.name.demodulize.pluralize.downcase
end

Instance Method Details

#saveObject



32
33
34
35
36
37
# File 'lib/yandex/direct/base.rb', line 32

def save
  if self.valid?
    response = Direct.request('add', self.class.path, {'Campaigns' => [self.to_param]})
    puts response.inspect
  end
end

#to_paramObject



28
29
30
# File 'lib/yandex/direct/base.rb', line 28

def to_param
  self.serializable_hash(except: [:errors, :validation_context])
end