Sha256: 4b0d604da119d5f3ba361f6cfb825cd01d3026f75d279bcb2f41f82ec17c9e00
Contents?: true
Size: 842 Bytes
Versions: 6
Compression:
Stored size: 842 Bytes
Contents
module Unidom::ArticleNumber::Concerns::AsMarked extend ActiveSupport::Concern included do |includer| has_many :markings, class_name: 'Unidom::ArticleNumber::Marking', as: :marked def is_marked!(as: nil, by: nil, at: Time.now) raise ArgumentError.new('The as argument is required.') if as.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! barcode: as, marker: by, opened_at: at end def is_marked?(as: nil, at: Time.now) raise ArgumentError.new('The as argument is required.') if as.blank? raise ArgumentError.new('The at argument is required.') if at.blank? markings.barcode_is(as).valid_at(now: at).alive.exists? end end module ClassMethods end end
Version data entries
6 entries across 6 versions & 1 rubygems