Sha256: 943771580e5fb6356ed9da97df1858daf88ea9a27e36b0f18d0f9ac262e2f21c
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
## # As Barcode 是条形码的领域逻辑关注点。 module Unidom module ArticleNumber module Concerns module 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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
unidom-article_number-3.0.1 | app/models/unidom/article_number/concerns/as_barcode.rb |