Sha256: 12cf8ae427baa2dbf82a1011e2ce1f38a3a6bbb7734a384ae50ab31238959f64
Contents?: true
Size: 1.04 KB
Versions: 11
Compression:
Stored size: 1.04 KB
Contents
## # As Barcode 是条形码的领域逻辑关注点。 module Unidom::ArticleNumber::Concerns::AsBarcode extend ActiveSupport::Concern included do |includer| has_many :markings, class_name: 'Unidom::ArticleNumber::Marking', as: :barcode has_many :marked_products, through: :markings, source: :marked, source_type: 'Unidom::Product::Product' def mark!(marked, by: nil, at: Time.now) raise ArgumentError.new('The marked argument is required.') if marked.blank? raise ArgumentError.new('The by argument is required.' ) if by.blank? raise ArgumentError.new('The at argument is required.' ) if at.blank? markings.create! marked: marked, marker: by, opened_at: at end def mark?(marked, at: Time.now) raise ArgumentError.new('The marked argument is required.') if marked.blank? raise ArgumentError.new('The at argument is required.' ) if at.blank? markings.marked_is(marked).valid_at(now: at).alive.exists? end end module ClassMethods end end
Version data entries
11 entries across 11 versions & 1 rubygems