Class: Mccloud::Templates

Inherits:
Hash
  • Object
show all
Defined in:
lib/mccloud/templates.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#envObject (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

Returns:

  • (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

#pathObject



23
24
25
# File 'lib/mccloud/templates.rb', line 23

def path
  @env.config.mccloud.template_path
end

#registered?(name) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/mccloud/templates.rb', line 31

def registered?(name)
  return self.has_key?(name)
end