Class: Keenser::Computer

Inherits:
Model
  • Object
show all
Defined in:
lib/keenser/model/computer.rb

Constant Summary collapse

Roles =
[:server, :client]

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

each, #find_or_create, schema, without_tables

Class Method Details

.localObject



20
21
22
# File 'lib/keenser/model/computer.rb', line 20

def self.local
  @local ||= where(name: `hostname`).first
end

Instance Method Details

#validateObject



12
13
14
15
16
17
18
# File 'lib/keenser/model/computer.rb', line 12

def validate
  super
  errors.add :name, "can't be empty" if name.empty?
  errors.add :role, "must be one of: #{Roles.join ', '}" unless Roles.include? role.to_sym
  errors.add :music, "directory does not exist" unless Dir.exists? music
  errors.add :playlists, "directory does not exist" unless Dir.exists? playlists
end