Class: Circus::Agents::CommandParams
- Inherits:
-
Object
- Object
- Circus::Agents::CommandParams
- Defined in:
- lib/circus/agents/params.rb
Instance Method Summary collapse
-
#initialize(str) ⇒ CommandParams
constructor
A new instance of CommandParams.
- #optional(*names) ⇒ Object
- #required(*names) ⇒ Object
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 |