Sha256: 80a643f468dc1df477df75841ab8e40c0cf31128840d2bdded3f9b06d5c79e9c

Contents?: true

Size: 442 Bytes

Versions: 14

Compression:

Stored size: 442 Bytes

Contents

class Cart < ActiveRecord::Base
  include DiscoApp::Concerns::Synchronises

  belongs_to :shop, class_name: 'DiscoApp::Shop'

  SHOPIFY_API_CLASS = ShopifyAPI::Cart

  before_save :set_token

  def self.synchronise_by(shop, data)
    { token: data['token'] }
  end

  def total_price
    data['line_items'].map { |line_item| line_item['line_price'].to_f }.sum
  end

  private

    def set_token
      self.token = data['token']
    end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
disco_app-0.10.5 test/dummy/app/models/cart.rb
disco_app-0.11.0 test/dummy/app/models/cart.rb
disco_app-0.11.1 test/dummy/app/models/cart.rb
disco_app-0.12.0 test/dummy/app/models/cart.rb
disco_app-0.12.1 test/dummy/app/models/cart.rb
disco_app-0.12.5 test/dummy/app/models/cart.rb
disco_app-0.12.6 test/dummy/app/models/cart.rb
disco_app-0.12.7 test/dummy/app/models/cart.rb
disco_app-0.13.0 test/dummy/app/models/cart.rb
disco_app-0.13.1 test/dummy/app/models/cart.rb
disco_app-0.13.2 test/dummy/app/models/cart.rb
disco_app-0.13.3 test/dummy/app/models/cart.rb
disco_app-0.13.4 test/dummy/app/models/cart.rb
disco_app-0.12.7.pre.puma.pre.3 test/dummy/app/models/cart.rb