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
-
#base_application ⇒ Class
Returns the alternate application class or defaults to Rails.application.
-
#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
#base_application ⇒ Class
Returns the alternate application class or defaults to Rails.application
52 53 54 |
# File 'lib/brainstem/api_docs/introspectors/rails_introspector.rb', line 52 def base_application base_application_class.present? ? base_application_class.constantize : ::Rails.application end |
#controllers ⇒ Array<Class>
Returns a list of controllers that descend from the base controller class.
43 44 45 |
# File 'lib/brainstem/api_docs/introspectors/rails_introspector.rb', line 43 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? base_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.
33 34 35 |
# File 'lib/brainstem/api_docs/introspectors/rails_introspector.rb', line 33 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.
63 64 65 |
# File 'lib/brainstem/api_docs/introspectors/rails_introspector.rb', line 63 def routes routes_method.call end |