Sha256: 10124f8d3ab0f66276c0837df247d285ecd96054b29c875cceca8f15f2a4d91f
Contents?: true
Size: 1.47 KB
Versions: 8
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
8 entries across 8 versions & 1 rubygems