Module: Taggable::Page::InstanceMethods

Defined in:
lib/taggable/page.rb

Instance Method Summary collapse

Instance Method Details

#has_pointer?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/taggable/page.rb', line 24

def has_pointer?
  !pointer.nil?
end

#tags_for_cloud(limit = 50, bands = 6) ⇒ Object

note varying logic here: tag clouds are used differently when describing a group. if only one object is relevant, all of its tags will be equally (locally) important. Presumably that cloud should show global tag importance. If several objects are relevant, either from a list or a tree of descendants, we

probably want to show local tag importance, ie prominence within that list.



34
35
36
37
# File 'lib/taggable/page.rb', line 34

def tags_for_cloud(limit=50, bands=6)
  tags = Tag.attached_to(self.with_children).visible.most_popular(limit)
  Tag.sized(tags, bands)
end

#with_childrenObject

the family-tree builder works with generations instead of individuals to cut down the number of retrieval steps



41
42
43
44
45
46
47
48
49
50
# File 'lib/taggable/page.rb', line 41

def with_children
  this_generation = [self]
  return this_generation unless self.respond_to?(:children) && self.children.any?
  family = [self]
  while this_generation.any? && next_generation = self.class.children_of(this_generation)
    family.push(*next_generation)
    this_generation = next_generation
  end
  family
end