Class: Teapot::Loader
- Inherits:
-
Object
- Object
- Teapot::Loader
- Defined in:
- lib/teapot/loader.rb
Overview
Loads the teapot.rb script and can reload it if it was changed.
Instance Attribute Summary collapse
-
#script ⇒ Object
readonly
Returns the value of attribute script.
Instance Method Summary collapse
- #changed? ⇒ Boolean
-
#initialize(context, package, path = TEAPOT_FILE) ⇒ Loader
constructor
A new instance of Loader.
- #reload ⇒ Object
- #teapot_path ⇒ Object
Constructor Details
#initialize(context, package, path = TEAPOT_FILE) ⇒ Loader
Returns a new instance of Loader.
145 146 147 148 149 150 151 152 153 |
# File 'lib/teapot/loader.rb', line 145 def initialize(context, package, path = TEAPOT_FILE) @context = context @package = package @path = path @mtime = nil @script, @mtime = load! end |
Instance Attribute Details
#script ⇒ Object (readonly)
Returns the value of attribute script.
155 156 157 |
# File 'lib/teapot/loader.rb', line 155 def script @script end |
Instance Method Details
#changed? ⇒ Boolean
161 162 163 |
# File 'lib/teapot/loader.rb', line 161 def changed? File.mtime(teapot_path) > @mtime end |
#reload ⇒ Object
165 166 167 |
# File 'lib/teapot/loader.rb', line 165 def reload self.class.new(@context, @package, @path) end |
#teapot_path ⇒ Object
157 158 159 |
# File 'lib/teapot/loader.rb', line 157 def teapot_path @package.path + @path end |