Sha256: e0798d339718460a2f2fbe2a26ba1eac1a630bb607ab5bb1c5bb91a5e791f7de

Contents?: true

Size: 640 Bytes

Versions: 6

Compression:

Stored size: 640 Bytes

Contents

class SpudSnippet < ActiveRecord::Base

  validates :name, :presence => true
  validates_uniqueness_of :name, :scope => :site_id

  scope :site, lambda {|sid| where(:site_id => sid)}

  acts_as_spud_liquid_content

  def postprocess_content
    template = Liquid::Template.parse(self.content)
    self.content_processed = template.render()
  end

  def content_processed=(content)
    write_attribute(:content_processed,content)
  end

  def content_processed
    if read_attribute(:content_processed).blank?
      self.update_column(:content_processed, postprocess_content)
    end
    return read_attribute(:content_processed)
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tb_cms-1.1.5 app/models/spud_snippet.rb
tb_cms-1.1.4 app/models/spud_snippet.rb
tb_cms-1.1.3 app/models/spud_snippet.rb
tb_cms-1.1.2 app/models/spud_snippet.rb
tb_cms-1.1.1 app/models/spud_snippet.rb
tb_cms-1.1.0 app/models/spud_snippet.rb