Class: Circus::Agents::CommandParams

Inherits:
Object
  • Object
show all
Defined in:
lib/circus/agents/params.rb

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ CommandParams

Returns a new instance of CommandParams.



6
7
8
9
10
11
12
# File 'lib/circus/agents/params.rb', line 6

def initialize(str)
  @params = if str
    Encoding.decode(str)
  else
    {}
  end
end

Instance Method Details

#optional(*names) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/circus/agents/params.rb', line 23

def optional(*names)
  res = names.map do |n|
    if  @params.has_key? n
      @params[n]
    else
      nil
    end
  end
  format_result(res)
end

#required(*names) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/circus/agents/params.rb', line 14

def required(*names)
  res = names.map do |n|
    raise MissingParameterException.new(n) unless @params.has_key? n
  
    @params[n]
  end
  format_result(res)
end