Sha256: a32d391619416d78faff82eab3e7ba69a7c227e721ba29878d6b682d19bff696

Contents?: true

Size: 437 Bytes

Versions: 10

Compression:

Stored size: 437 Bytes

Contents

class Cart < ApplicationRecord
  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

10 entries across 10 versions & 1 rubygems

Version Path
disco_app-0.16.1.pre.sidekiq.pre.6.pre.release test/dummy/app/models/cart.rb
disco_app-0.14.1 test/dummy/app/models/cart.rb
disco_app-0.14.2 test/dummy/app/models/cart.rb
disco_app-0.15.0 test/dummy/app/models/cart.rb
disco_app-0.16.0 test/dummy/app/models/cart.rb
disco_app-0.14.4 test/dummy/app/models/cart.rb
disco_app-0.14.3 test/dummy/app/models/cart.rb
disco_app-0.16.1 test/dummy/app/models/cart.rb
disco_app-0.15.2 test/dummy/app/models/cart.rb
disco_app-0.14.0 test/dummy/app/models/cart.rb