Class: Para::Breadcrumbs::Breadcrumb

Inherits:
Object
  • Object
show all
Defined in:
lib/para/breadcrumbs/breadcrumb.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier, path, *options) ⇒ Breadcrumb

Returns a new instance of Breadcrumb.



6
7
8
9
10
# File 'lib/para/breadcrumbs/breadcrumb.rb', line 6

def initialize(identifier, path, *options)
  @identifier = identifier
  @_path = path
  @options = options
end

Instance Attribute Details

#_pathObject (readonly)

Returns the value of attribute _path.



4
5
6
# File 'lib/para/breadcrumbs/breadcrumb.rb', line 4

def _path
  @_path
end

#identifierObject (readonly)

Returns the value of attribute identifier.



4
5
6
# File 'lib/para/breadcrumbs/breadcrumb.rb', line 4

def identifier
  @identifier
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/para/breadcrumbs/breadcrumb.rb', line 4

def options
  @options
end

Instance Method Details

#active?(request) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/para/breadcrumbs/breadcrumb.rb', line 32

def active?(request)
  path == request.path || !_path
end

#pathObject

Allow lazy evaluation of routes to define breadcrumbs before being able to access request or routes



22
23
24
25
26
27
28
29
30
# File 'lib/para/breadcrumbs/breadcrumb.rb', line 22

def path
  @path ||= if Symbol === _path
    find_route_for(_path, *options)
  elsif _path
    _path
  else
    '#'
  end
end

#titleObject



12
13
14
15
16
17
18
# File 'lib/para/breadcrumbs/breadcrumb.rb', line 12

def title
  @title ||= if Symbol === identifier
    ::I18n.t("admin.breadcrumbs.#{ identifier }")
  else
    identifier
  end
end