Class: ActiveAnalytics::AssetsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/active_analytics/assets_controller.rb

Constant Summary collapse

@@root =
ActiveAnalytics::Engine.root.join("app/views", controller_path + "/").to_s

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.endpointsObject



11
12
13
14
15
16
# File 'app/controllers/active_analytics/assets_controller.rb', line 11

def self.endpoints
  return @endpoints if @endpoints
  paths = Dir["#{@@root}**/*"].keep_if { |path| File.file?(path) }
  files = paths.map { |path| path.to_s.delete_prefix(@@root).delete_suffix(".erb") }
  @endpoints = files.delete_if { |str| str.start_with?("_") }
end

Instance Method Details

#showObject



18
19
20
21
22
23
24
25
# File 'app/controllers/active_analytics/assets_controller.rb', line 18

def show
  if self.class.endpoints.include?(params[:file])
    expires_in(1.day, public: true)
    render_asset(params[:file])
  else
    raise ActionController::RoutingError.new("Not found #{params[:file]}")
  end
end