Sha256: d809dc5270a39d6d6c2aadac0de87c8f51fc013cb4e5bf9104c6cd55abfe0d3e

Contents?: true

Size: 901 Bytes

Versions: 1

Compression:

Stored size: 901 Bytes

Contents

module Orchestrator
    class AccessLog < Couchbase::Model
        design_document :alog
        include ::CouchbaseId::Generator


        TTL = Rails.env.production? ? 2.weeks.to_i : 120


        belongs_to :user,      class_name: "::User"
        attribute  :systems,   default: lambda { [] }

        attribute :persisted,  default: false
        attribute :suspected,  default: false
        attribute :notes

        attribute :created_at
        attribute :ended_at
        attribute :last_checked_at, default: 0


        def initialize(*args)
            super(*args)

            if self.created_at.nil?
                self.created_at = Time.now.to_i
            end
        end

        def save
            self.last_checked_at = Time.now.to_i

            if self.persisted
                super
            else
                super(ttl: TTL)
            end
        end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
orchestrator-1.0.3 app/models/orchestrator/access_log.rb