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.



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

def options
  @options
end

Instance Method Details

#content=(value) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'app/models/cms_template.rb', line 11

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

#deserialize_yamlObject



21
22
23
# File 'app/models/cms_template.rb', line 21

def deserialize_yaml
  @options = YAML.load(self.options_yaml) if self.options_yaml
end

#serialize_yamlObject



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

def serialize_yaml
  self.options_yaml = YAML.dump(@options)
end