Sha256: 1bbcc48b044e337d0987e86ab9e863ed577013235587d7d995b7fcb6e4cdec39

Contents?: true

Size: 834 Bytes

Versions: 1

Compression:

Stored size: 834 Bytes

Contents

class RePipelineActivated < RePipelineBase
  belongs_to :re_pipeline, :foreign_key => :parent_re_pipeline_id
  
  def self.find_by_code(code)
    return find_by_code_without_caching(code) unless RulesEngine::Cache.perform_caching?

    re_pipeline = RulesEngine::Cache.cache_store.read("activated_pipeline_#{code}")
    if (re_pipeline.nil?)
      re_pipeline = find_by_code_without_caching(code)

      RulesEngine::Cache.cache_store.write("activated_pipeline_#{code}", re_pipeline)
    end    

    re_pipeline
  end

  def self.find_by_code_without_caching(code)
    RePipelineActivated.find(:first, :conditions => ["code = ?", code], :include => :re_rules)
  end

  def self.reset_cache(code)
    return unless RulesEngine::Cache.perform_caching?
    RulesEngine::Cache.cache_store.delete("activated_pipeline_#{code}")
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rules_engine-0.0.1 rails_generators/templates/app/models/re_pipeline_activated.rb