Class: Brainstem::ApiDocs::Introspectors::AbstractIntrospector

Inherits:
Object
  • Object
show all
Includes:
Concerns::Optional
Defined in:
lib/brainstem/api_docs/introspectors/abstract_introspector.rb

Direct Known Subclasses

RailsIntrospector

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Concerns::Optional

#initialize

Class Method Details

.with_loaded_environment(options = {}) ⇒ AbstractIntrospector

Returns a new instance of the introspector with the environment loaded, ready for introspection.

Parameters:

  • options (Hash) (defaults to: {})

    arguments to pass on to the instance

Returns:



18
19
20
# File 'lib/brainstem/api_docs/introspectors/abstract_introspector.rb', line 18

def self.with_loaded_environment(options = {})
  new(options).tap(&:load_environment!)
end

Instance Method Details

#controllersArray<Class>

Override to return a collection of all controller classes.

Returns:

  • (Array<Class>)

    all controller classes to document

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/brainstem/api_docs/introspectors/abstract_introspector.rb', line 26

def controllers
  raise NotImplementedError
end

#presentersArray<Class>

Override to return a collection of all presenter classes.

Returns:

  • (Array<Class>)

    all presenter classes to document

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/brainstem/api_docs/introspectors/abstract_introspector.rb', line 34

def presenters
  raise NotImplementedError
end

#routesObject

Override to return a collection of hashes with the minimum following keys:

+:path+ - the relative path (i.e. the endpoint)
+:controller+ - the managing controller
+:action+ - the managing action
+:http_method+ - an array of the HTTP methods this route is available on.

Raises:

  • (NotImplementedError)


47
48
49
# File 'lib/brainstem/api_docs/introspectors/abstract_introspector.rb', line 47

def routes
  raise NotImplementedError
end

#valid?Boolean

Provides both a sanity check to ensure that output confirms to interface and also confirms that there is actually something to generate docs for.

Returns:

  • (Boolean)

    Whether the Introspector is valid



57
58
59
# File 'lib/brainstem/api_docs/introspectors/abstract_introspector.rb', line 57

def valid?
  valid_controllers? && valid_presenters? && valid_routes?
end

#valid_optionsObject



9
10
11
# File 'lib/brainstem/api_docs/introspectors/abstract_introspector.rb', line 9

def valid_options
  [ ]
end