Module: Broadway::Hierarchical::InstanceMethods

Defined in:
lib/broadway/mixins/hierarchical.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



8
9
10
# File 'lib/broadway/mixins/hierarchical.rb', line 8

def children
  @children
end

#parentObject

Returns the value of attribute parent.



8
9
10
# File 'lib/broadway/mixins/hierarchical.rb', line 8

def parent
  @parent
end

#show_childrenObject

Returns the value of attribute show_children.



8
9
10
# File 'lib/broadway/mixins/hierarchical.rb', line 8

def show_children
  @show_children
end

Instance Method Details

#num_childrenObject



56
57
58
# File 'lib/broadway/mixins/hierarchical.rb', line 56

def num_children
  children.length
end

#show_children?Boolean

def children

  unless @children
    key = self.categories.last
    length = self.path.split("/").length
    @children = site.send("find_#{short_name.pluralize}_by_category", key)
    @children.delete_if do |child|
      (child.path == self.path) ||
      (child.path.split("/").length <= length)
    end
  end

  @children
end

Returns:

  • (Boolean)


51
52
53
54
# File 'lib/broadway/mixins/hierarchical.rb', line 51

def show_children?
  return true if self.data.blank?
  return self.show_children == true
end