Sha256: 3bc519e05587ff7a222dd09124fe49eb868a1951bef4a035609d66222ae151f1

Contents?: true

Size: 1.16 KB

Versions: 16

Compression:

Stored size: 1.16 KB

Contents

require 'aws-sdk'
require 'alephant/logger'

module Alephant
  module Publisher
    class InvalidKeySpecifiedError < StandardError; end

    class Options
      attr_reader :queue, :writer

      QUEUE_OPTS = [
        :receive_wait_time,
        :sqs_queue_url,
        :visibility_timeout
      ]

      WRITER_OPTS = [
        :lookup_table_name,
        :msg_vary_id_path,
        :renderer_id,
        :s3_bucket_id,
        :s3_object_path,
        :sequence_id_path,
        :sequencer_table_name,
        :view_path
      ]

      def initialize
        @queue  = {}
        @writer = {}
      end

      def add_queue(opts)
        execute @queue, QUEUE_OPTS, opts
      end

      def add_writer(opts)
        execute @writer, WRITER_OPTS, opts
      end

      private

      def execute(instance, type, opts)
        begin
          validate type, opts
          instance.merge! opts
        rescue Exception => e
          puts e.message
        end
      end

      def validate(type, opts)
        opts.each do |key, value|
          raise InvalidKeySpecifiedError, "The key '#{key}' is invalid" unless type.include? key.to_sym
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
alephant-publisher-0.6.2 lib/alephant/publisher/options.rb
alephant-publisher-0.6.1 lib/alephant/publisher/options.rb
alephant-publisher-0.5.1 lib/alephant/publisher/options.rb
alephant-publisher-0.5.0 lib/alephant/publisher/options.rb
alephant-publisher-0.4.0 lib/alephant/publisher/options.rb
alephant-publisher-0.3.1 lib/alephant/publisher/options.rb
alephant-publisher-0.3.0 lib/alephant/publisher/options.rb
alephant-publisher-0.2.9 lib/alephant/publisher/options.rb
alephant-publisher-0.2.8 lib/alephant/publisher/options.rb
alephant-publisher-0.2.7 lib/alephant/publisher/options.rb
alephant-publisher-0.2.6 lib/alephant/publisher/options.rb
alephant-publisher-0.2.5 lib/alephant/publisher/options.rb
alephant-publisher-0.2.4 lib/alephant/publisher/options.rb
alephant-publisher-0.2.3 lib/alephant/publisher/options.rb
alephant-publisher-0.2.2 lib/alephant/publisher/options.rb
alephant-publisher-0.2.1 lib/alephant/publisher/options.rb