Sha256: 47d46fd63b7602e607033358eab76b86cac3ec5bb285816567e32079e0ff8116

Contents?: true

Size: 745 Bytes

Versions: 4

Compression:

Stored size: 745 Bytes

Contents

module EasySwaggerUi
  class Configuration
    # Configurable options
    OPTIONS = [
      :base_path,
      :cache_enabled,
      :cache_timeout,
      :cache_store,
      :validator_enabled,
    ].freeze

    attr_accessor(*OPTIONS)

    # Avoid method redefined warning
    remove_method :base_path=, :cache_store=
    # remove_method :cache_store=

    # Make sure it's an absolute path
    def base_path=(path)
      @base_path = File.absolute_path(path, Rails.root)
    end

    # Evaluate lambda when needed
    def cache_store=(store)
      @cache_store = store.respond_to?(:call) ? store.call : store
    end

    def to_h
      OPTIONS.each_with_object({}) do |key, config|
        config[key] = send(key)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
easy_swagger_ui-0.1.3 lib/easy_swagger_ui/configuration.rb
easy_swagger_ui-0.1.2 lib/easy_swagger_ui/configuration.rb
easy_swagger_ui-0.1.1 lib/easy_swagger_ui/configuration.rb
easy_swagger_ui-0.1.0 lib/easy_swagger_ui/configuration.rb