Class: Para::Breadcrumbs::Breadcrumb
- Inherits:
-
Object
- Object
- Para::Breadcrumbs::Breadcrumb
- Defined in:
- lib/para/breadcrumbs/breadcrumb.rb
Instance Attribute Summary collapse
-
#_path ⇒ Object
readonly
Returns the value of attribute _path.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #active?(request) ⇒ Boolean
-
#initialize(identifier, path, *options) ⇒ Breadcrumb
constructor
A new instance of Breadcrumb.
-
#path ⇒ Object
Allow lazy evaluation of routes to define breadcrumbs before being able to access request or routes.
- #title ⇒ Object
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, *) @identifier = identifier @_path = path @options = end |
Instance Attribute Details
#_path ⇒ Object (readonly)
Returns the value of attribute _path.
4 5 6 |
# File 'lib/para/breadcrumbs/breadcrumb.rb', line 4 def _path @_path end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
4 5 6 |
# File 'lib/para/breadcrumbs/breadcrumb.rb', line 4 def identifier @identifier end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/para/breadcrumbs/breadcrumb.rb', line 4 def @options end |
Instance Method Details
#active?(request) ⇒ Boolean
32 33 34 |
# File 'lib/para/breadcrumbs/breadcrumb.rb', line 32 def active?(request) path == request.path || !_path end |
#path ⇒ Object
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, *) elsif _path _path else '#' end end |
#title ⇒ Object
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 |