Sha256: c0c97dbcb2f5440fd0120b28932724e1b4b9d65289f62da1ed8d23ae5f790975

Contents?: true

Size: 945 Bytes

Versions: 4

Compression:

Stored size: 945 Bytes

Contents

# frozen_string_literal: true

module RailsServerMonitor
  class Server < ApplicationRecord
    self.table_name = "rails_server_monitor_servers"
    store :system_information, accessors: %i(
      system_os
      system_os_language
      system_os_timezone
      system_kernel_version
      system_cpu_name
      system_cpu_cores
      system_cpu_frequency
      system_ram_available_in_mb
      system_hdd_available_in_gb
    ), coder: JSON

    belongs_to :group, class_name: "RailsServerMonitor::ServerGroup", counter_cache: true, optional: true
    has_many :server_snapshots, class_name: "RailsServerMonitor::ServerSnapshot",
             foreign_key: :rails_server_monitor_server_id,
             dependent: :delete_all

    before_save :squish_text

    def display_name
      @display_name ||= custom_name.present? ? custom_name : hostname
    end

    def squish_text
      self.custom_name = self.custom_name&.squish
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails-server-monitor-0.2.1 app/models/rails_server_monitor/server.rb
rails-server-monitor-0.2.0 app/models/rails_server_monitor/server.rb
rails-server-monitor-0.1.10 app/models/rails_server_monitor/server.rb
rails-server-monitor-0.1.9 app/models/rails_server_monitor/server.rb