class RspecApiDocumentation::Configuration

Attributes

parent[R]

Public Class Methods

add_setting(name, opts = {}) click to toggle source
# File lib/rspec_api_documentation/configuration.rb, line 41
def self.add_setting(name, opts = {})
  define_method("#{name}=") { |value| settings[name] = value }
  define_method("#{name}") do
    if settings.has_key?(name)
      settings[name]
    elsif opts[:default].respond_to?(:call)
      opts[:default].call(self)
    else
      opts[:default]
    end
  end
end
new(parent = nil) click to toggle source
# File lib/rspec_api_documentation/configuration.rb, line 7
def initialize(parent = nil)
  @parent = parent
  @settings = parent.settings.clone if parent
end

Public Instance Methods

client_method() click to toggle source
# File lib/rspec_api_documentation/configuration.rb, line 140
def client_method
  @client_method ||= :client
end
client_method=(new_client_method) click to toggle source
# File lib/rspec_api_documentation/configuration.rb, line 129
    def client_method=(new_client_method)
      return if new_client_method == client_method

      RspecApiDocumentation::DSL::Resource.module_eval <<-RUBY
        alias :#{new_client_method} #{client_method}
        undef #{client_method}
      RUBY

      @client_method = new_client_method
    end
define_group(name) { |subconfig| ... } click to toggle source

Defines a new sub configuration

Automatically sets the `filter` to the group name, and the `docs_dir` to a subfolder of the parent's `doc_dir` named the group name.

RspecApiDocumentation.configure do |config|
  config.docs_dir = "doc/api"
  config.define_group(:public) do |config|
    # Default values
    config.docs_dir = "doc/api/public"
    config.filter = :public
  end
end

Params:

name

String name of the group

block

Block configuration block

# File lib/rspec_api_documentation/configuration.rb, line 33
def define_group(name, &block)
  subconfig = self.class.new(self)
  subconfig.filter = name
  subconfig.docs_dir = self.docs_dir.join(name.to_s)
  yield subconfig
  groups << subconfig
end
disable_dsl_method!() click to toggle source
# File lib/rspec_api_documentation/configuration.rb, line 150
    def disable_dsl_method!
      RspecApiDocumentation::DSL::Endpoint.module_eval <<-RUBY
        undef method
      RUBY
    end
disable_dsl_status!() click to toggle source
# File lib/rspec_api_documentation/configuration.rb, line 144
    def disable_dsl_status!
      RspecApiDocumentation::DSL::Endpoint.module_eval <<-RUBY
        undef status
      RUBY
    end
each() { |self| ... } click to toggle source

Yields itself and sub groups to hook into the Enumerable module

# File lib/rspec_api_documentation/configuration.rb, line 161
def each(&block)
  yield self
  groups.map { |g| g.each &block }
end
groups() click to toggle source
# File lib/rspec_api_documentation/configuration.rb, line 12
def groups
  @groups ||= []
end
settings() click to toggle source
# File lib/rspec_api_documentation/configuration.rb, line 156
def settings
  @settings ||= {}
end