Sha256: 503de8ad952d0f4e08d433ef9859e2468aeef22db4138b4e8e6049d3311c46ae

Contents?: true

Size: 704 Bytes

Versions: 13

Compression:

Stored size: 704 Bytes

Contents

# frozen_string_literal: true

module Bullion
  module Models
    # ACMEv2 Authorization model
    class Authorization < ActiveRecord::Base
      serialize :identifier, coder: JSON

      after_initialize :init_values, unless: :persisted?

      belongs_to :order
      has_many :challenges

      validates :status, inclusion: { in: %w[invalid pending ready processing valid deactivated] }

      def init_values
        self.expires ||= Time.now + (60 * 60)
      end

      def prep_challenges!
        %w[http-01 dns-01].each do |type|
          chall = Challenge.new
          chall.authorization = self
          chall.acme_type = type

          chall.save
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
bullion-0.7.3 lib/bullion/models/authorization.rb
bullion-0.7.2 lib/bullion/models/authorization.rb
bullion-0.7.1 lib/bullion/models/authorization.rb
bullion-0.7.0 lib/bullion/models/authorization.rb
bullion-0.6.2 lib/bullion/models/authorization.rb
bullion-0.6.1 lib/bullion/models/authorization.rb
bullion-0.6.0 lib/bullion/models/authorization.rb
bullion-0.5.1 lib/bullion/models/authorization.rb
bullion-0.5.0 lib/bullion/models/authorization.rb
bullion-0.4.3 lib/bullion/models/authorization.rb
bullion-0.4.2 lib/bullion/models/authorization.rb
bullion-0.4.1 lib/bullion/models/authorization.rb
bullion-0.4.0 lib/bullion/models/authorization.rb