Class: CmsTemplate

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/cms_template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'app/models/cms_template.rb', line 5

def options
  @options
end

Instance Method Details

#after_findObject



9
10
11
12
# File 'app/models/cms_template.rb', line 9

def after_find
  require 'yaml'
  @options = YAML.load(self.options_yaml) if self.options_yaml
end

#before_saveObject



24
25
26
27
# File 'app/models/cms_template.rb', line 24

def before_save
  require 'yaml'
  self.options_yaml = YAML.dump(@options)
end

#content=(value) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'app/models/cms_template.rb', line 14

def content=(value)
  if value && value.is_a?(String)
    # filter suspicious content... go overboard for now, fine-tune later perhaps
    value.gsub!(/<(%.*?(exec|system)\s?\(.*?\s*%)>/, '&lt;\1&gt;')
    value.gsub!(/<(%.*?\%x\s?\[.*?\s*%)>/, '&lt;\1&gt;')
    value.gsub!(/<(%.*?`.*?\s*%)>/, '&lt;\1&gt;')
  end
  super(value)
end