Class: OsCtld::Commands::Event::Broadcast
- Includes:
- OsCtl::Lib::Utils::Log
- Defined in:
- lib/osctld/commands/event/broadcast.rb
Instance Attribute Summary
Attributes inherited from Base
#client, #client_handler, #id, #opts
Instance Method Summary collapse
Methods inherited from Base
#base_execute, #call_cmd, #call_cmd!, #error, #error!, handle, #handled, #indirect?, #initialize, #manipulate, #manipulation_holder, #ok, #progress, #request_stop, run, run!
Constructor Details
This class inherits a constructor from OsCtld::Commands::Base
Instance Method Details
#execute ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/osctld/commands/event/broadcast.rb', line 9 def execute begin events = opts.fetch(:events) rescue KeyError => e error!("missing events: #{e.}") end events.each do |event| begin event_type = event.fetch(:type) event_opts = event.fetch(:opts) rescue KeyError => e error!("invalid options: #{e.}") end if !event_type.is_a?(String) error!('type must be a string') elsif !event_opts.is_a?(Hash) error!('opts must be a hash') end Eventd.broadcast(event_type, **event_opts) end ok end |