app/models/unidom/certificate/concerns/as_certification.rb in unidom-certificate-3.0 vs app/models/unidom/certificate/concerns/as_certification.rb in unidom-certificate-3.0.1

- old
+ new

@@ -1,43 +1,51 @@ ## # As Certification 是证书的领域关注点。 -module Unidom::Certificate::Concerns::AsCertification +module Unidom + module Certificate + module Concerns - extend ActiveSupport::Concern - include Unidom::Common::Concerns::ArgumentValidation + module AsCertification - included do |includer| + extend ActiveSupport::Concern + include Unidom::Common::Concerns::ArgumentValidation - has_many :certificatings, class_name: 'Unidom::Certificate::Certificating', as: :certification + included do |includer| - ## - # 用证书去认证参与者(被认证者)。 by 是认证者, at 是认证时间(缺省为当前时间)。 - # 如:mcse.certificate! person, by: bill_gates, at: Time.now - def certificate!(certificated, by: nil, at: Time.now) + has_many :certificatings, class_name: 'Unidom::Certificate::Certificating', as: :certification - assert_present! :certificated, certificated - assert_present! :by, by - assert_present! :at, at + ## + # 用证书去认证参与者(被认证者)。 by 是认证者, at 是认证时间(缺省为当前时间)。 + # 如:mcse.certificate! person, by: bill_gates, at: Time.now + def certificate!(certificated, by: nil, at: Time.now) - certificatings.certificated_is(certificated).valid_at(now: at).alive.first_or_create! certificator: by, opened_at: at + assert_present! :certificated, certificated + assert_present! :by, by + assert_present! :at, at - end + certificatings.certificated_is(certificated).valid_at(now: at).alive.first_or_create! certificator: by, opened_at: at - ## - # 判断当前认证书在指定的时间 at (缺省为当前时间)是否对被认证者 certificated 生效。如: - # mcse.certificated? person, at: Time.now - def certificate?(certificated, at: Time.now) + end - assert_present! :certificated, certificated - assert_present! :at, at + ## + # 判断当前认证书在指定的时间 at (缺省为当前时间)是否对被认证者 certificated 生效。如: + # mcse.certificated? person, at: Time.now + def certificate?(certificated, at: Time.now) - certificatings.certificated_is(certificated).valid_at(now: at).alive.exists? + assert_present! :certificated, certificated + assert_present! :at, at - end + certificatings.certificated_is(certificated).valid_at(now: at).alive.exists? - end + end - module ClassMethods - end + end + module ClassMethods + end + + end + + end + end end