Sha256: d9be359b9a13080b76ff05521ac08d37f452f441417e546f4facd5b1903a7a64
Contents?: true
Size: 1.06 KB
Versions: 9
Compression:
Stored size: 1.06 KB
Contents
module PatronusFati::DataModels class Connection include DataMapper::Resource include PatronusFati::DataModels::ExpirationAttributes property :id, Serial property :connected_at, Integer, :default => Proc.new { Time.now.to_i } property :disconnected_at, Integer, :default => Proc.new { Time.now.to_i } property :duration, Integer belongs_to :access_point belongs_to :client def self.connected all(:disconnected_at => nil) end def self.disconnected all(:disconnected_at.not => nil) end def self.current_expiration_threshold Time.now.to_i - PatronusFati::CONNECTION_EXPIRATION end def connected? disconnected_at.nil? end def disconnect! update(disconnected_at: Time.now.to_i, duration: duration) if connected? end def duration self[:duration] || (Time.now.to_i - connected_at) end def full_state { access_point: access_point.bssid, client: client.bssid, connected: connected? } end end end
Version data entries
9 entries across 9 versions & 1 rubygems