Class: Shutterbug::Handlers::JsFileHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/shutterbug/handlers/js_file_handler.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeJsFileHandler

Returns a new instance of JsFileHandler.



17
18
19
# File 'lib/shutterbug/handlers/js_file_handler.rb', line 17

def initialize
  @javascript = File.read(js_file).gsub(/URL_PREFIX/, self.class.config.url_prefix)
end

Class Method Details

.configObject



5
6
7
# File 'lib/shutterbug/handlers/js_file_handler.rb', line 5

def self.config
  Configuration.instance
end

.js_pathObject



9
10
11
# File 'lib/shutterbug/handlers/js_file_handler.rb', line 9

def self.js_path
  "#{self.config.url_prefix}/shutterbug.js"
end

.regexObject



13
14
15
# File 'lib/shutterbug/handlers/js_file_handler.rb', line 13

def self.regex
  /#{self.config.path_prefix}\/shutterbug.js/
end

Instance Method Details

#handle(helper, req, env) ⇒ Object



25
26
27
# File 'lib/shutterbug/handlers/js_file_handler.rb', line 25

def handle(helper, req, env)
  helper.response(@javascript, 'application/javascript')
end

#js_fileObject



21
22
23
# File 'lib/shutterbug/handlers/js_file_handler.rb', line 21

def js_file
  File.join(File.dirname(__FILE__), "shutterbug.js")
end