Class: Happy::Extras::CodeReloader

Inherits:
Controller show all
Defined in:
lib/happy/extras/code_reloader.rb

Constant Summary

Constants inherited from Controller

Controller::CASCADING_SETTINGS

Instance Attribute Summary

Attributes inherited from Controller

#env, #processed_path, #unprocessed_path

Attributes included from Helpers::Rendering

#output_buffer

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Controller

#app, #current_url, helpers, #initialize, #params, #request, #response, #root_url, #session

Methods included from Helpers::I18n

#localize, #translate

Methods included from Helpers::Rendering

#capture_template_block, #concat_output, #render, #render_resource, #render_template, #with_output_buffer

Methods included from Helpers::Html

#escape_html, #html_tag, #html_tag_attributes, #link_to, #preserve, #url_for

Methods included from Controller::Permissions

#permissions

Methods included from Controller::Configurable

included, #set, #settings

Methods included from Controller::Rackable

#handle_request, included

Methods included from Controller::Actions

#cache_control, #content_type, #halt!, #header, #layout, #max_age, #only_if_path_matches, #redirect!, #run, #serve!

Methods included from Controller::Routing

#on, #path_to_regexp

Constructor Details

This class inherits a constructor from Happy::Controller

Class Method Details

.reload_app_codeObject


5
6
7
8
9
10
# File 'lib/happy/extras/code_reloader.rb', line 5

def reload_app_code
  Dir[config[:directory]].each do |f|
    load f
  end
  @app_code_loaded = true
end

.reload_app_code?Boolean


12
13
14
# File 'lib/happy/extras/code_reloader.rb', line 12

def reload_app_code?
  Happy.env.development? || !@app_code_loaded
end

Instance Method Details

#routeObject


17
18
19
20
21
22
23
# File 'lib/happy/extras/code_reloader.rb', line 17

def route
  raise "no directory specified" unless config[:directory]
  raise "no controller specified" unless config[:controller]

  self.class.reload_app_code if self.class.reload_app_code?
  run eval(config[:controller])
end