Class: Extension
- Inherits:
-
Object
- Object
- Extension
- Defined in:
- lib/yodel/application/extension.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#layouts_dir ⇒ Object
readonly
Returns the value of attribute layouts_dir.
-
#lib_dir ⇒ Object
readonly
Returns the value of attribute lib_dir.
-
#migrations_dir ⇒ Object
readonly
Returns the value of attribute migrations_dir.
-
#models_dir ⇒ Object
readonly
Returns the value of attribute models_dir.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#public_dir ⇒ Object
readonly
Returns the value of attribute public_dir.
Instance Method Summary collapse
-
#initialize ⇒ Extension
constructor
A new instance of Extension.
- #load! ⇒ Object
Constructor Details
#initialize ⇒ Extension
Returns a new instance of Extension.
4 5 6 7 8 9 10 11 |
# File 'lib/yodel/application/extension.rb', line 4 def initialize @environment = @name.end_with?('environment') @migrations_dir = File.join(@lib_dir, Yodel::MIGRATIONS_DIRECTORY_NAME) @public_dir = File.join(@lib_dir, Yodel::PUBLIC_DIRECTORY_NAME) @layouts_dir = File.join(@lib_dir, Yodel::LAYOUTS_DIRECTORY_NAME) @models_dir = File.join(@lib_dir, Yodel::MODELS_DIRECTORY_NAME) Yodel.extensions[@name] = self end |
Instance Attribute Details
#layouts_dir ⇒ Object (readonly)
Returns the value of attribute layouts_dir.
2 3 4 |
# File 'lib/yodel/application/extension.rb', line 2 def layouts_dir @layouts_dir end |
#lib_dir ⇒ Object (readonly)
Returns the value of attribute lib_dir.
2 3 4 |
# File 'lib/yodel/application/extension.rb', line 2 def lib_dir @lib_dir end |
#migrations_dir ⇒ Object (readonly)
Returns the value of attribute migrations_dir.
2 3 4 |
# File 'lib/yodel/application/extension.rb', line 2 def migrations_dir @migrations_dir end |
#models_dir ⇒ Object (readonly)
Returns the value of attribute models_dir.
2 3 4 |
# File 'lib/yodel/application/extension.rb', line 2 def models_dir @models_dir end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/yodel/application/extension.rb', line 2 def name @name end |
#public_dir ⇒ Object (readonly)
Returns the value of attribute public_dir.
2 3 4 |
# File 'lib/yodel/application/extension.rb', line 2 def public_dir @public_dir end |
Instance Method Details
#load! ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/yodel/application/extension.rb', line 13 def load! unless @environment require_extension Yodel.config.public_directories << @public_dir if File.directory?(@public_dir) Yodel.config.layout_directories << @layouts_dir if File.directory?(@layouts_dir) Yodel.config.extensions << self end # load any models. if the init.rb file exists it will be loaded instead, # allowing extensions to specify the order models are loaded. if File.exist?(@models_dir) init_file = File.join(@models_dir, 'init.rb') if File.exist?(init_file) require init_file else Dir[File.join(@models_dir, '**')].sort.each do |model| next if model.start_with?('.') require File.realpath(model, @models_dir) end end end end |