Class: Ecm::CmsCore::Template
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Ecm::CmsCore::Template
- Defined in:
- app/models/ecm/cms_core/template.rb
Defined Under Namespace
Classes: Resolver
Class Method Summary collapse
Instance Method Summary collapse
- #available_locale ⇒ Object
- #filename ⇒ Object
- #formatted_partial_flag ⇒ Object
- #normalize_locale ⇒ Object
- #set_defaults ⇒ Object
- #to_s ⇒ Object
- #update_pathname ⇒ Object
- #update_pathname! ⇒ Object
Class Method Details
.partials ⇒ Object
55 56 57 |
# File 'app/models/ecm/cms_core/template.rb', line 55 def self.partials where("partial = ?", true) end |
.templates ⇒ Object
59 60 61 |
# File 'app/models/ecm/cms_core/template.rb', line 59 def self.templates where("partial = ?", false) end |
Instance Method Details
#available_locale ⇒ Object
21 22 23 |
# File 'app/models/ecm/cms_core/template.rb', line 21 def available_locale I18n.available_locales.map(&:to_s).include?(self.locale) end |
#filename ⇒ Object
63 64 65 66 67 68 69 |
# File 'app/models/ecm/cms_core/template.rb', line 63 def filename if format.blank? "#{basename}.#{locale}.#{handler}" else "#{basename}.#{locale}.#{format}.#{handler}" end end |
#formatted_partial_flag ⇒ Object
71 72 73 |
# File 'app/models/ecm/cms_core/template.rb', line 71 def formatted_partial_flag ::I18n.t(self.partial.to_s) end |
#normalize_locale ⇒ Object
25 26 27 |
# File 'app/models/ecm/cms_core/template.rb', line 25 def normalize_locale self.locale = self.locale.to_s end |
#set_defaults ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/models/ecm/cms_core/template.rb', line 29 def set_defaults if self.new_record? self.locale ||= I18n.default_locale # self.format ||= 'html' self.handler ||= 'texterb' end end |
#to_s ⇒ Object
75 76 77 |
# File 'app/models/ecm/cms_core/template.rb', line 75 def to_s "#{self.pathname}#{self.basename}" end |
#update_pathname ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'app/models/ecm/cms_core/template.rb', line 37 def update_pathname self.pathname = self.folder.fullname unless self.folder.blank? # if self.folder.blank? # self.pathname = "/" # else # self.pathname = self.folder.fullname # end end |
#update_pathname! ⇒ Object
46 47 48 49 |
# File 'app/models/ecm/cms_core/template.rb', line 46 def update_pathname! self.update_pathname self.save! end |