Sha256: 1771354197f63c68d8253c4b809bff05070a6aa9b5d1fb5fb6c764f1e4ad7f23

Contents?: true

Size: 925 Bytes

Versions: 1

Compression:

Stored size: 925 Bytes

Contents

module Outpost
  # Provides the DSL used to configure Scouts in Outposts.
  class ScoutConfig
    attr_reader :options, :reports

    def initialize
      @reports = {}
      @options = {}
    end

    # Reads/writes any options. It will passed down to the Scout.
    # @param [Object] args Any argument that will be passed to the Scout.
    # Rreturn [Object] The associated option
    def options(args=nil)
      if args.nil?
        @options
      else
        @options = args
      end
    end

    # Reads reporting as:
    #   report :up, :response_code => 200
    #
    # It reads much better in the DSL, but doesn't make
    # much sense in terms of code, so it is changed to
    # an inverted approach, so:
    #   status = 200
    #   params = {:response_code => 200}
    #
    # gets stored as:
    #    {:response_code => 200} = up
    def report(status, params)
      @reports[params] = status
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outpost-0.2.0 lib/outpost/scout_config.rb