Class: Template

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/generators/ecm/cms_core/models/templates/template.rb

Defined Under Namespace

Classes: Resolver

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.partialsObject



25
26
27
# File 'lib/generators/ecm/cms_core/models/templates/template.rb', line 25

def self.partials
  where("partial = ?", true)
end

.templatesObject



29
30
31
# File 'lib/generators/ecm/cms_core/models/templates/template.rb', line 29

def self.templates
  where("partial = ?", false)
end

Instance Method Details

#filenameObject



33
34
35
36
37
38
39
# File 'lib/generators/ecm/cms_core/models/templates/template.rb', line 33

def filename
  if format.blank?
  "#{basename}.#{locale}.#{handler}"
  else    
    "#{basename}.#{locale}.#{format}.#{handler}"
  end
end

#formatted_partial_flagObject



41
42
43
# File 'lib/generators/ecm/cms_core/models/templates/template.rb', line 41

def formatted_partial_flag
  I18n.t(self.partial.to_s)
end

#to_sObject



45
46
47
# File 'lib/generators/ecm/cms_core/models/templates/template.rb', line 45

def to_s
  "#{self.pathname}#{self.basename}"
end

#update_pathnameObject



12
13
14
# File 'lib/generators/ecm/cms_core/models/templates/template.rb', line 12

def update_pathname
  self.pathname = self.folder.fullname
end

#update_pathname!Object



16
17
18
19
# File 'lib/generators/ecm/cms_core/models/templates/template.rb', line 16

def update_pathname!
  self.update_pathname
  self.save
end