Class: Slugable::SlugBuilder::CachingTreeAncestry
- Inherits:
-
TreeAncestry
- Object
- TreeAncestry
- Slugable::SlugBuilder::CachingTreeAncestry
- Defined in:
- lib/slugable/slug_builder/caching_tree_ancestry.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
Attributes inherited from TreeAncestry
Instance Method Summary collapse
-
#initialize(options) ⇒ CachingTreeAncestry
constructor
A new instance of CachingTreeAncestry.
- #to_slug(record) ⇒ Object
Methods inherited from TreeAncestry
Constructor Details
#initialize(options) ⇒ CachingTreeAncestry
Returns a new instance of CachingTreeAncestry.
6 7 8 9 |
# File 'lib/slugable/slug_builder/caching_tree_ancestry.rb', line 6 def initialize() super @cache = .fetch(:cache) end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
4 5 6 |
# File 'lib/slugable/slug_builder/caching_tree_ancestry.rb', line 4 def cache @cache end |
Instance Method Details
#to_slug(record) ⇒ Object
11 12 13 |
# File 'lib/slugable/slug_builder/caching_tree_ancestry.rb', line 11 def to_slug(record) record.path_ids.map{ |id| cache.read_slug(slug_column, id) }.select(&:present?) end |