class Opener::Daemons::Mapper

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]

Constants

INPUT_SCHEMA

Path to the schema file.

@return [String]

SCHEMA_DIRECTORY

The directory containing JSON schema files.

@return [String]

Attributes

component[R]
component_options[R]

Public Class Methods

new(component, component_options = {}) click to toggle source

@param [Class] component @param [Hash] component_options

# File lib/opener/daemons/mapper.rb, line 34
def initialize(component, component_options = {})
  @component         = component
  @component_options = component_options
end

Public Instance Methods

map_input(message) click to toggle source

@param [AWS::SQS::ReceivedMessage] message @return [Hash]

# File lib/opener/daemons/mapper.rb, line 43
def map_input(message)
  decoded = JSON(message.body)

  validate_input!(decoded)

  return Configuration.new(component, component_options, decoded)
end
validate_input!(input) click to toggle source

Validates the given input Hash.

@param [Hash] input @raise [JSON::Schema::ValidationError]

# File lib/opener/daemons/mapper.rb, line 57
def validate_input!(input)
  JSON::Validator.validate!(INPUT_SCHEMA, input)
end