Class: Mccloud::Templates
- Inherits:
-
Hash
- Object
- Hash
- Mccloud::Templates
- Defined in:
- lib/mccloud/templates.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#initialize(env) ⇒ Templates
constructor
A new instance of Templates.
- #load! ⇒ Object
- #path ⇒ Object
- #registered?(name) ⇒ Boolean
Constructor Details
#initialize(env) ⇒ Templates
Returns a new instance of Templates.
7 8 9 |
# File 'lib/mccloud/templates.rb', line 7 def initialize(env) @env=env end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
5 6 7 |
# File 'lib/mccloud/templates.rb', line 5 def env @env end |
Instance Method Details
#exists? ⇒ Boolean
27 28 29 |
# File 'lib/mccloud/templates.rb', line 27 def exists? File.directory?(self.path) end |
#load! ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/mccloud/templates.rb', line 11 def load! if self.exists? Dir[File.join(self.path,"**")].each do |dir| template_name=File.basename(dir) t=Template.new(template_name,env) self[template_name]=t end else env.logger.info "Skipping loading of definitions as the definition_path does exist" end end |
#path ⇒ Object
23 24 25 |
# File 'lib/mccloud/templates.rb', line 23 def path @env.config.mccloud.template_path end |
#registered?(name) ⇒ Boolean
31 32 33 |
# File 'lib/mccloud/templates.rb', line 31 def registered?(name) return self.has_key?(name) end |