Sha256: 735786421e5a22ae06918f79cecf8e4a593f3002e48437525012adfb24951e56

Contents?: true

Size: 1002 Bytes

Versions: 14

Compression:

Stored size: 1002 Bytes

Contents

=begin
This class is responsible for maintaining an index table Templates so that we can directly find a
given template for a kpath, format and mode. The indexing process is triggered by the Property
gem.
=end
class IdxTemplate < ActiveRecord::Base
  before_create :set_site_id

  def self.set_property_index(template, indices)
    if template.version.status >= Zena::Status::Pub
      # create or update index
      if index = first(:conditions => ['node_id = ?', template.id])
        if template.tkpath
          index.update_attributes(indices)
        else
          index.destroy
        end
      elsif template.tkpath
        create(indices.merge(:node_id => template.id, :version_id => template.version.id))
      end
    else
      # remove index
      delete_all(['node_id = ?', template.version.id])
    end
  end

  def self.delete_property_index(template)
    delete_all(['node_id = ?', template.id])
  end

  private
    def set_site_id
      self[:site_id] = current_site.id
    end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
zena-1.2.8 app/models/idx_template.rb
zena-1.2.7 app/models/idx_template.rb
zena-1.2.6 app/models/idx_template.rb
zena-1.2.5 app/models/idx_template.rb
zena-1.2.4 app/models/idx_template.rb
zena-1.2.3 app/models/idx_template.rb
zena-1.2.2 app/models/idx_template.rb
zena-1.2.1 app/models/idx_template.rb
zena-1.2.0 app/models/idx_template.rb
zena-1.1.3 app/models/idx_template.rb
zena-1.1.2 app/models/idx_template.rb
zena-1.1.1 app/models/idx_template.rb
zena-1.1.0 app/models/idx_template.rb
zena-1.0.0 app/models/idx_template.rb