Class: Sandals::CodeReloader
- Inherits:
-
Object
- Object
- Sandals::CodeReloader
- Defined in:
- lib/sandals/code_reloader.rb
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(path) ⇒ CodeReloader
constructor
A new instance of CodeReloader.
Constructor Details
#initialize(path) ⇒ CodeReloader
Returns a new instance of CodeReloader.
9 10 11 12 13 14 15 |
# File 'lib/sandals/code_reloader.rb', line 9 def initialize(path) @path = File.(path) @signature = signature @version = 1 @error = nil @mutex = Mutex.new end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/sandals/code_reloader.rb', line 7 def path @path end |
Instance Method Details
#check ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sandals/code_reloader.rb', line 17 def check @mutex.synchronize do current_signature = signature return result unless current_signature != @signature @signature = current_signature application = Sandals.load(path) @version += 1 @error = nil Result.new(@version, application, nil, true) rescue SyntaxError, LoadError, StandardError => error @error = error_details(error) result(changed: true) end end |