Class: MultiDaemons::Validate

Inherits:
Object
  • Object
show all
Defined in:
lib/multi_daemons/validate.rb

Class Method Summary collapse

Class Method Details

.valid_daemon?(daemon) ⇒ Boolean

Returns:

  • (Boolean)

4
5
6
7
8
9
10
11
12
13
14
# File 'lib/multi_daemons/validate.rb', line 4

def valid_daemon?(daemon)
  name = daemon.name
  return daemon_name_error unless name && name.length > 1

  daemon.name = name.to_s if name.is_a?(Symbol)
  case daemon.type
  when :proc, 'proc'
    return daemon_proc_error unless daemon.daemon.is_a?(Proc)
  end
  true
end

.valid_multi_daemon?(multi_daemon) ⇒ Boolean

Returns:

  • (Boolean)

16
17
18
19
20
21
22
23
24
# File 'lib/multi_daemons/validate.rb', line 16

def valid_multi_daemon?(multi_daemon)
  if multi_daemon.is_a?(Array) && !multi_daemon.empty?
    if multi_daemon.all? { |daemon| daemon.is_a?(MultiDaemons::Daemon) }
      return true
    end
  end
  invalid_multi_daemon_option
  false
end