Class: Aerogel::Reloader
- Inherits:
-
Object
- Object
- Aerogel::Reloader
- Defined in:
- lib/aerogel/core/reloader.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#files ⇒ Object
Returns the value of attribute files.
-
#group ⇒ Object
Returns the value of attribute group.
-
#opts ⇒ Object
Returns the value of attribute opts.
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, files, opts = {}, &blk) ⇒ Reloader
constructor
Use as middleware:.
Constructor Details
#initialize(app, files, opts = {}, &blk) ⇒ Reloader
Use as middleware:
# single file
use Aerogel::Reloader, "file1.rb" { load 'file1.rb' }
# list of files
use Aerogel::Reloader, ["file1.rb", "file2.rb"] do |files|
files.each{|f| load f }
end
# dynamic list of files
use Aerogel::Reloader, ->(){ Dir.glob["*.rb"] } do |files|
files.each{|f| load f}
end
# named groups of files
use Aerogel::Reloader, "routes/*.rb", group: :routes do |files|
files.each{|f| load f }
end
# adding observer on a named group
use Aerogel::Reloader, :routes, before: true do |files|
# do more stuff before group :routes is reloaded
end
Valid are:
:group => name group of files
:before => if true invoke action block before group is reloaded
:after => if true invoke action block after group is reloaded
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/aerogel/core/reloader.rb', line 39 def initialize( app, files, opts = {}, &blk ) @app = app if files.is_a? Symbol @group = files @files = nil else @files = files @group = opts[:group] end @opts = opts @action = blk @file_list = file_list( @files ) if @files @signature = signature( @file_list ) if @file_list Aerogel::Reloader.reloaders << self end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
6 7 8 |
# File 'lib/aerogel/core/reloader.rb', line 6 def action @action end |
#files ⇒ Object
Returns the value of attribute files.
6 7 8 |
# File 'lib/aerogel/core/reloader.rb', line 6 def files @files end |
#group ⇒ Object
Returns the value of attribute group.
6 7 8 |
# File 'lib/aerogel/core/reloader.rb', line 6 def group @group end |
#opts ⇒ Object
Returns the value of attribute opts.
6 7 8 |
# File 'lib/aerogel/core/reloader.rb', line 6 def opts @opts end |
Class Method Details
.reloaders ⇒ Object
60 61 62 |
# File 'lib/aerogel/core/reloader.rb', line 60 def self.reloaders @reloaders ||= [] end |
Instance Method Details
#call(env) ⇒ Object
55 56 57 58 |
# File 'lib/aerogel/core/reloader.rb', line 55 def call( env ) check! @app.call( env ) end |