Class: CamaleonRecord
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- CamaleonRecord
- Includes:
- ActiveRecordExtras::Relation
- Defined in:
- app/models/camaleon_record.rb
Direct Known Subclasses
CamaleonCms::CustomField, CamaleonCms::CustomFieldsRelationship, CamaleonCms::Media, CamaleonCms::Meta, CamaleonCms::PostComment, CamaleonCms::PostDefault, CamaleonCms::PostRelationship, CamaleonCms::TermRelationship, CamaleonCms::TermTaxonomy, CamaleonCms::User, Plugins::Attack::Models::Attack
Constant Summary collapse
- TRANSLATION_TAG_HIDE_MAP =
{ '<!--' => '!--', '-->' => '--!' }.freeze
- TRANSLATION_TAG_HIDE_REGEX =
Regexp.new(TRANSLATION_TAG_HIDE_MAP.keys.map { |x| Regexp.escape(x) }.join('|')).freeze
- TRANSLATION_TAG_RESTORE_MAP =
{ '--!' => '-->', '!--' => '<!--' }.freeze
- TRANSLATION_TAG_RESTORE_REGEX =
Regexp.new(TRANSLATION_TAG_RESTORE_MAP.keys.map { |x| Regexp.escape(x) }.join('|')).freeze
Instance Method Summary collapse
-
#cama_build_cache_key(key) ⇒ Object
internal helper to generate cache key.
-
#cama_fetch_cache(key) ⇒ Object
fetch the cache value for this key.
-
#cama_get_cache(key) ⇒ Object
return the cache value for this key.
-
#cama_remove_cache(key) ⇒ Object
remove cache value for this key.
-
#cama_set_cache(key, val) ⇒ Object
save cache value for this key.
Instance Method Details
#cama_build_cache_key(key) ⇒ Object
internal helper to generate cache key
49 50 51 |
# File 'app/models/camaleon_record.rb', line 49 def cama_build_cache_key(key) _key = "cama_cache_#{self.class.name}_#{id}_#{key}" end |
#cama_fetch_cache(key) ⇒ Object
fetch the cache value for this key
27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/camaleon_record.rb', line 27 def cama_fetch_cache(key) @cama_cache_vars ||= {} _key = cama_build_cache_key(key) if @cama_cache_vars.key?(_key) # puts "*********** using model cache var: #{_key}" else @cama_cache_vars[_key] = yield end @cama_cache_vars[_key] end |
#cama_get_cache(key) ⇒ Object
return the cache value for this key
39 40 41 42 43 44 45 46 |
# File 'app/models/camaleon_record.rb', line 39 def cama_get_cache(key) @cama_cache_vars ||= {} begin @cama_cache_vars[cama_build_cache_key(key)] rescue StandardError nil end end |
#cama_remove_cache(key) ⇒ Object
remove cache value for this key
22 23 24 |
# File 'app/models/camaleon_record.rb', line 22 def cama_remove_cache(key) @cama_cache_vars.delete(cama_build_cache_key(key)) end |
#cama_set_cache(key, val) ⇒ Object
save cache value for this key
15 16 17 18 19 |
# File 'app/models/camaleon_record.rb', line 15 def cama_set_cache(key, val) @cama_cache_vars ||= {} @cama_cache_vars[cama_build_cache_key(key)] = val val end |