Class: Tuttle::RailsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/tuttle/rails_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#check_reload_status

Instance Method Details

#assetsObject



34
35
36
37
# File 'app/controllers/tuttle/rails_controller.rb', line 34

def assets
  @sprockets = Rails.application.assets
  @engines = @sprockets.instance_variable_get(:@engines)
end

#controllersObject



11
12
13
14
15
16
17
18
19
# File 'app/controllers/tuttle/rails_controller.rb', line 11

def controllers
  # TODO: Both ObjectSpace and .descendants approaches have issues with class reloading during development
  # It seems likely that .descendants will work best when Tuttle and Rails classes are not modified
  # but both approaches also require eager_load to be true
  # @controllers = ObjectSpace.each_object(::Class).select {|klass| klass < ActionController::Base }
  @controllers = ActionController::Base.descendants
  @controllers.reject! {|controller| controller <= Tuttle::ApplicationController || controller.abstract?}
  @controllers.sort_by!(&:name)
end

#databaseObject



26
27
28
# File 'app/controllers/tuttle/rails_controller.rb', line 26

def database
  @conn = ActiveRecord::Base.connection
end

#helpersObject



30
31
32
# File 'app/controllers/tuttle/rails_controller.rb', line 30

def helpers
  @helpers = ::ApplicationController.send(:modules_for_helpers,[:all])
end

#indexObject



7
8
9
# File 'app/controllers/tuttle/rails_controller.rb', line 7

def index
  Rails::Generators.lookup! if Rails::Generators.subclasses.empty?
end

#instrumentationObject



46
47
48
49
# File 'app/controllers/tuttle/rails_controller.rb', line 46

def instrumentation
  @events = Tuttle::Engine.events
  @event_counts = Tuttle::Engine.event_counts
end

#modelsObject



21
22
23
24
# File 'app/controllers/tuttle/rails_controller.rb', line 21

def models
  @models = ActiveRecord::Base.descendants
  @models.sort_by!(&:name)
end

#routesObject



39
40
41
42
43
44
# File 'app/controllers/tuttle/rails_controller.rb', line 39

def routes
  @routes = Rails.application.routes.routes.collect do |route|
    ActionDispatch::Routing::RouteWrapper.new(route)
  end
  # TODO: include engine-mounted routes
end