Class: Rivendell::Import::Cart::Updater

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

Direct Known Subclasses

ApiUpdater, DbUpdater

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cart) ⇒ Updater

Returns a new instance of Updater.



74
75
76
# File 'lib/rivendell/import/cart.rb', line 74

def initialize(cart)
  @cart = cart
end

Instance Attribute Details

#cartObject

Returns the value of attribute cart.



72
73
74
# File 'lib/rivendell/import/cart.rb', line 72

def cart
  @cart
end

Instance Method Details

#empty_title?(title) ⇒ Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/rivendell/import/cart.rb', line 79

def empty_title?(title)
  [ nil, "", "[new cart]" ].include? title
end

#title_with_defaultObject



83
84
85
86
87
88
89
90
# File 'lib/rivendell/import/cart.rb', line 83

def title_with_default
  @title_with_default ||=
    if title
      title
    else
      default_title if default_title && empty_title?(current_title)
    end
end

#updateObject



92
93
94
95
96
97
98
99
# File 'lib/rivendell/import/cart.rb', line 92

def update
  begin
    update!
  rescue => e
    Rivendell::Import.logger.debug "#{self.class.name} failed : #{e}"
    false
  end
end