Class: Rivendell::Import::Cart::DbUpdater

Inherits:
Updater
  • Object
show all
Defined in:
lib/rivendell/import/cart.rb

Instance Attribute Summary

Attributes inherited from Updater

#cart

Instance Method Summary collapse

Methods inherited from Updater

#empty_title?, #initialize, #title_with_default, #update

Constructor Details

This class inherits a constructor from Rivendell::Import::Cart::Updater

Instance Method Details

#current_cartObject



132
133
134
# File 'lib/rivendell/import/cart.rb', line 132

def current_cart
  @current_cart ||= Rivendell::DB::Cart.get(number)
end

#current_titleObject



136
137
138
# File 'lib/rivendell/import/cart.rb', line 136

def current_title
  current_cart.title
end

#update!Object



140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/rivendell/import/cart.rb', line 140

def update!
  Database.init

  if title_with_default or artist or album or not scheduler_codes.empty?
    Rivendell::Import.logger.debug "Update Cart by DB"
    current_cart.title = title_with_default if title_with_default
    current_cart.scheduler_codes = scheduler_codes unless scheduler_codes.empty?
    current_cart.artist = artist if artist
    current_cart.album = album if album
    current_cart.save
  end
end