Class: Brainstem::ApiDocs::Introspectors::RailsIntrospector
- Inherits:
-
AbstractIntrospector
- Object
- AbstractIntrospector
- Brainstem::ApiDocs::Introspectors::RailsIntrospector
- Defined in:
- lib/brainstem/api_docs/introspectors/rails_introspector.rb
Instance Method Summary collapse
-
#controllers ⇒ Array<Class>
Returns a list of controllers that descend from the base controller class.
-
#load_environment! ⇒ Object
Loads ./config/environment.rb (by default) and eager loads all classes (otherwise
#descendants
returns an empty set). -
#presenters ⇒ Array<Class>
Returns a list of presenters that descend from the base presenter class.
-
#routes ⇒ Array<Hash>
Returns an array of hashes describing the endpoints of the application.
Methods inherited from AbstractIntrospector
#valid?, with_loaded_environment
Methods included from Concerns::Optional
Instance Method Details
#controllers ⇒ Array<Class>
Returns a list of controllers that descend from the base controller class.
45 46 47 |
# File 'lib/brainstem/api_docs/introspectors/rails_introspector.rb', line 45 def controllers base_controller_class.constantize.descendants end |
#load_environment! ⇒ Object
Loads ./config/environment.rb (by default) and eager loads all classes (otherwise #descendants
returns an empty set).
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/brainstem/api_docs/introspectors/rails_introspector.rb', line 16 def load_environment! load rails_environment_file unless env_already_loaded? ::Rails.application.eager_load! validate! rescue LoadError => e raise IncorrectIntrospectorForAppException, "Hosting app does not appear to be a Rails app." + "You may have to manually specify an Introspector (#{e.})." end |
#presenters ⇒ Array<Class>
Returns a list of presenters that descend from the base presenter class.
34 35 36 |
# File 'lib/brainstem/api_docs/introspectors/rails_introspector.rb', line 34 def presenters base_presenter_class.constantize.descendants end |
#routes ⇒ Array<Hash>
Returns an array of hashes describing the endpoints of the application. See routes_method
for the keys of those hashes.
57 58 59 |
# File 'lib/brainstem/api_docs/introspectors/rails_introspector.rb', line 57 def routes routes_method.call end |