Sha256: ea2fa35491937f3dcf36d985ef78da883109583660867ac47a79fb190a86c4bf
Contents?: true
Size: 1.47 KB
Versions: 22
Compression:
Stored size: 1.47 KB
Contents
module Opener module Daemons ## # Maps the input/output between the daemon and the worker in such a format # that both ends can work with it easily. # # @!attribute [r] component # @return [Class] # # @!attribute [r] component_options # @return [Hash] # class Mapper < Oni::Mapper attr_reader :component, :component_options ## # The directory containing JSON schema files. # # @return [String] # SCHEMA_DIRECTORY = File.expand_path('../../../../schema', __FILE__) ## # Path to the schema file. # # @return [String] # INPUT_SCHEMA = File.join(SCHEMA_DIRECTORY, 'sqs_input.json') ## # @param [Class] component # @param [Hash] component_options # def initialize(component, component_options = {}) @component = component @component_options = component_options end ## # @param [AWS::SQS::ReceivedMessage] message # @return [Hash] # def map_input(message) decoded = JSON(message.body) validate_input!(decoded) return Configuration.new(component, component_options, decoded) end ## # Validates the given input Hash. # # @param [Hash] input # @raise [JSON::Schema::ValidationError] # def validate_input!(input) JSON::Validator.validate!(INPUT_SCHEMA, input) end end # Mapper end # Daemons end # Opener
Version data entries
22 entries across 22 versions & 1 rubygems