Class: Milktea::Config
- Inherits:
-
Object
- Object
- Milktea::Config
- Defined in:
- lib/milktea/config.rb
Overview
Configuration class for Milktea applications
Instance Attribute Summary collapse
-
#autoload_dirs ⇒ Object
Returns the value of attribute autoload_dirs.
-
#hot_reloading ⇒ Object
writeonly
Sets the attribute hot_reloading.
-
#output ⇒ Object
Returns the value of attribute output.
- #renderer ⇒ Object
- #runtime ⇒ Object
Instance Method Summary collapse
- #autoload_paths ⇒ Object
- #hot_reloading? ⇒ Boolean
-
#initialize {|_self| ... } ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize {|_self| ... } ⇒ Config
Returns a new instance of Config.
9 10 11 12 13 14 15 16 17 |
# File 'lib/milktea/config.rb', line 9 def initialize @autoload_dirs = ["app/models"] @output = $stdout @hot_reloading = nil # Will be set by lazy evaluation @runtime = nil # Will be set by lazy evaluation @renderer = nil # Will be set by lazy evaluation yield(self) if block_given? end |
Instance Attribute Details
#autoload_dirs ⇒ Object
Returns the value of attribute autoload_dirs.
6 7 8 |
# File 'lib/milktea/config.rb', line 6 def autoload_dirs @autoload_dirs end |
#hot_reloading=(value) ⇒ Object (writeonly)
Sets the attribute hot_reloading
7 8 9 |
# File 'lib/milktea/config.rb', line 7 def hot_reloading=(value) @hot_reloading = value end |
#output ⇒ Object
Returns the value of attribute output.
6 7 8 |
# File 'lib/milktea/config.rb', line 6 def output @output end |
#renderer ⇒ Object
27 28 29 |
# File 'lib/milktea/config.rb', line 27 def renderer @renderer ||= Renderer.new(@output) end |
#runtime ⇒ Object
23 24 25 |
# File 'lib/milktea/config.rb', line 23 def runtime @runtime ||= Runtime.new end |
Instance Method Details
#autoload_paths ⇒ Object
31 32 33 |
# File 'lib/milktea/config.rb', line 31 def autoload_paths @autoload_dirs.map { |dir| Milktea.root.join(dir) } end |
#hot_reloading? ⇒ Boolean
19 20 21 |
# File 'lib/milktea/config.rb', line 19 def hot_reloading? @hot_reloading || (Milktea.env == :development) end |