Sha256: 5148417c24fa2f29f83d80bedd91030e7134ad1b42a1ccb5914260812c5be10c

Contents?: true

Size: 1.83 KB

Versions: 9

Compression:

Stored size: 1.83 KB

Contents

module Garage
  module Docs
    class Config
      attr_accessor :document_root, :current_user_method, :authenticate,
        :console_app_uid, :console_app_secret, :remote_server,
        :docs_authorization_method, :docs_cache_enabled,
        :signout_path, :signout_request_method

      def initialize
        reset
      end

      def reset
        @document_root = Rails.root.join('doc/garage')
        @current_user_method = Proc.new { current_user }
        @authenticate = Proc.new {}
        @console_app_uid, @console_app_secret = nil, nil
        @remote_server = Proc.new {|request| "#{request.protocol}#{request.host_with_port}" }
        @docs_authorization_method = nil
        @docs_cache_enabled = true
        @signout_path = '/signout'
        @signout_request_method = :post
      end

      class Builder
        def initialize(config)
          @config = config
        end

        def document_root=(value)
          @config.document_root = value
        end

        def current_user_method(&block)
          @config.current_user_method = block
        end

        def authenticate(&block)
          @config.authenticate = block
        end

        def console_app_uid=(value)
          @config.console_app_uid = value
        end

        def console_app_secret=(value)
          @config.console_app_secret = value
        end

        def remote_server=(value)
          @config.remote_server = value
        end

        def docs_cache_enabled=(value)
          @config.docs_cache_enabled = value
        end

        def docs_authorization_method(&block)
          @config.docs_authorization_method = block
        end

        def signout_path=(value)
          @config.signout_path = value
        end

        def signout_request_method=(value)
          @config.signout_request_method = value.to_sym
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
the_garage-2.8.2 lib/garage/docs/config.rb
the_garage-2.8.1 lib/garage/docs/config.rb
the_garage-2.8.0 lib/garage/docs/config.rb
the_garage-2.7.0 lib/garage/docs/config.rb
the_garage-2.6.1 lib/garage/docs/config.rb
the_garage-2.6.0 lib/garage/docs/config.rb
the_garage-2.5.0 lib/garage/docs/config.rb
the_garage-2.4.4 lib/garage/docs/config.rb
the_garage-2.4.3 lib/garage/docs/config.rb