Class: IdxTemplate
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- IdxTemplate
- Defined in:
- app/models/idx_template.rb
Overview
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.
Class Method Summary collapse
Class Method Details
.delete_property_index(template) ⇒ Object
27 28 29 |
# File 'app/models/idx_template.rb', line 27 def self.delete_property_index(template) delete_all(['node_id = ?', template.id]) end |
.set_property_index(template, indices) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/idx_template.rb', line 9 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 |