Class: Reactive::Mvc::AssetsController

Inherits:
Object
  • Object
show all
Defined in:
lib/reactive-mvc/dispatcher.rb

Instance Method Summary collapse

Instance Method Details

#process(request, response) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/reactive-mvc/dispatcher.rb', line 111

def process(request, response)
  # Assets do not need any handling
  response.handler_name = false
  
  name = request.params[:asset]
  glob_path = if request.params[:kind] == :ui
    # construct a path like: {client/}name{_size}.*
    client, size, path = request.params[:client], request.params[:size], ""
    path << "{#{client}/,}" if client
    path << name
    path << "{_#{size},}" if size
    path << ".*"
    path
  else
    name
  end
  response.body = Reactive.file_for(:assets, glob_path) or raise Reactive::Dispatcher::AssetNotFound, "Can't find '#{glob_path}' in #{Reactive.dirs_for(:assets).join(', ')}"
end