Sha256: 009d0059425da2819992175c4c070eb77f656d60bf545d58e4c7df55862a46db

Contents?: true

Size: 837 Bytes

Versions: 2

Compression:

Stored size: 837 Bytes

Contents

require 'logger'

module Plaza
  class Configuration

    attr_accessor :middleware
    attr_accessor :default_middleware

    def initialize
      @default_middleware = [
        Plaza::Middleware::Exceptions,
        Plaza::Middleware::UserId
      ]
      @middleware = []
    end

    def middleware
      @middleware + default_middleware
    end

    def base_url(url = nil)
      url ? @url = url : @url
    end
    alias_method :base_url=, :base_url

    def cache_store(store = nil)
      store ? @cache_store = store : @cache_store
    end
    alias_method :cache_store=, :cache_store

    def logger(logger = nil)
      @logger ||= Logger.new(STDOUT)
      logger ? @logger = logger : @logger
    end
    alias_method :logger=, :logger

    def use(*ware)
      @middleware << ware
      @middleware.flatten!
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
plaza-0.1.1 lib/plaza/configuration.rb
plaza-0.1.0 lib/plaza/configuration.rb