class Trestle::Navigation::Group

Attributes

name[R]
options[R]

Public Class Methods

new(name, options={}) click to toggle source
# File lib/trestle/navigation/group.rb, line 6
def initialize(name, options={})
  @name = name
  @options = options
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/trestle/navigation/group.rb, line 20
def <=>(other)
  case other
  when Group
    priority <=> other.priority
  when NullGroup
    1
  end
end
==(other) click to toggle source
# File lib/trestle/navigation/group.rb, line 11
def ==(other)
  other.is_a?(self.class) && name == other.name
end
Also aliased as: eql?
collapse?() click to toggle source
# File lib/trestle/navigation/group.rb, line 44
def collapse?
  options[:collapse]
end
eql?(other)
Alias for: ==
hash() click to toggle source
# File lib/trestle/navigation/group.rb, line 16
def hash
  name.hash
end
id() click to toggle source
# File lib/trestle/navigation/group.rb, line 52
def id
  name.to_s.parameterize
end
label() click to toggle source
# File lib/trestle/navigation/group.rb, line 48
def label
  I18n.t("admin.navigation.groups.#{name}", default: name.to_s.titlecase)
end
merge(other) click to toggle source
# File lib/trestle/navigation/group.rb, line 29
def merge(other)
  self.class.new(name, options.merge(other.options))
end
priority() click to toggle source
# File lib/trestle/navigation/group.rb, line 33
def priority
  case options[:priority]
  when :first
    -Float::INFINITY
  when :last
    Float::INFINITY
  else
    options[:priority] || 0
  end
end