Sha256: 516642896295ca6c487834ff09bb9fdcf8830cc7b7e085b67ea8dc2795ab0e80

Contents?: true

Size: 911 Bytes

Versions: 4

Compression:

Stored size: 911 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?

    code.gsub!(/[^a-zA-Z0-9]+/i, '_')
    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?

    code.gsub!(/[^a-zA-Z0-9]+/i, '_')
    RulesEngine::Cache.cache_store.delete("activated_pipeline_#{code}")
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rules_engine-0.0.6 rails_generators/templates/app/models/re_pipeline_activated.rb
rules_engine-0.0.5 rails_generators/templates/app/models/re_pipeline_activated.rb
rules_engine-0.0.4 rails_generators/templates/app/models/re_pipeline_activated.rb
rules_engine-0.0.3 rails_generators/templates/app/models/re_pipeline_activated.rb