Method: Cosmos::TargetModel.packet
- Defined in:
- lib/cosmos/models/target_model.rb
.packet(target_name, packet_name, type: :TLM, scope:) ⇒ Hash
Returns Packet hash or raises an exception.
86 87 88 89 90 91 92 93 94 |
# File 'lib/cosmos/models/target_model.rb', line 86 def self.packet(target_name, packet_name, type: :TLM, scope:) raise "Unknown type #{type} for #{target_name} #{packet_name}" unless VALID_TYPES.include?(type) # Assume it exists and just try to get it to avoid an extra call to Store.exist? json = Store.hget("#{scope}__cosmos#{type.to_s.downcase}__#{target_name}", packet_name) raise "Packet '#{target_name} #{packet_name}' does not exist" if json.nil? JSON.parse(json) end |