Sha256: d14fe0bdb6bcb95464cb1130e02890d328bf516564fb90cff9a1d00def3ff3a1

Contents?: true

Size: 591 Bytes

Versions: 11

Compression:

Stored size: 591 Bytes

Contents

##
# As Shop 是购物场所的领域逻辑关注点。

module Unidom::Shopping::Concerns::AsShop

  extend ActiveSupport::Concern

  included do |includer|

    has_many :shopping_carts, class_name: 'Unidom::Shopping::ShoppingCart', as: :shop

    ##
    # 从当前商店中,获取购物车。购物者为 by 。获取时间为 at ,缺省为当前时间。如:
    # shop.get_cart! by: current_person
    def get_cart!(by: nil, at: Time.now)
      shopping_carts.shopped_by(by).valid_at(now: at).alive.first_or_create! opened_at: at
    end

  end

  module ClassMethods
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
unidom-shopping-2.0 app/models/unidom/shopping/concerns/as_shop.rb
unidom-shopping-1.7.8 app/models/unidom/shopping/concerns/as_shop.rb
unidom-shopping-1.7.7 app/models/unidom/shopping/concerns/as_shop.rb
unidom-shopping-1.7.6 app/models/unidom/shopping/concerns/as_shop.rb
unidom-shopping-1.7.5 app/models/unidom/shopping/concerns/as_shop.rb
unidom-shopping-1.7.4 app/models/unidom/shopping/concerns/as_shop.rb
unidom-shopping-1.7.3 app/models/unidom/shopping/concerns/as_shop.rb
unidom-shopping-1.7.2 app/models/unidom/shopping/concerns/as_shop.rb
unidom-shopping-1.7.1 app/models/unidom/shopping/concerns/as_shop.rb
unidom-shopping-1.7 app/models/unidom/shopping/concerns/as_shop.rb
unidom-shopping-1.6.5 app/models/unidom/shopping/concerns/as_shop.rb