Class: Neuron::Navigation::Title
- Inherits:
-
Object
- Object
- Neuron::Navigation::Title
- Defined in:
- lib/neuron/navigation.rb
Instance Attribute Summary collapse
-
#default_options ⇒ Object
Returns the value of attribute default_options.
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Class Method Summary collapse
Instance Method Summary collapse
- #head_title(title = nil, options = {}) ⇒ Object
-
#initialize(view, options = {}) ⇒ Title
constructor
A new instance of Title.
- #navigation_title(title = nil, options = {}) ⇒ Object
- #page_title(title = nil, options = {}) ⇒ Object
Constructor Details
#initialize(view, options = {}) ⇒ Title
Returns a new instance of Title.
17 18 19 20 21 22 23 |
# File 'lib/neuron/navigation.rb', line 17 def initialize(view, = {}) @view = view @navigation_title = nil @page_title = nil @head_title = nil @default_options = {title_separator: ' — '}.merge() end |
Instance Attribute Details
#default_options ⇒ Object
Returns the value of attribute default_options.
8 9 10 |
# File 'lib/neuron/navigation.rb', line 8 def @default_options end |
#view ⇒ Object (readonly)
Returns the value of attribute view.
9 10 11 |
# File 'lib/neuron/navigation.rb', line 9 def view @view end |
Class Method Details
.navigation_title(controller, action = :index, options = {}) ⇒ Object
12 13 14 |
# File 'lib/neuron/navigation.rb', line 12 def (controller, action = :index, = {}) I18n.t("navigation.#{controller}.#{action}", ) end |
Instance Method Details
#head_title(title = nil, options = {}) ⇒ Object
36 37 38 39 |
# File 'lib/neuron/navigation.rb', line 36 def head_title(title = nil, = {}) = .merge() @head_title ||= title.try(:to_s) || view.([, application.title].compact.join([:title_separator])) end |
#navigation_title(title = nil, options = {}) ⇒ Object
31 32 33 34 |
# File 'lib/neuron/navigation.rb', line 31 def (title = nil, = {}) = {default: @page_title || view.view_name.humanize}.merge().merge() @navigation_title ||= title.try(:to_s) || self.class.(view.controller_i18n_scope, view.view_name, ) end |
#page_title(title = nil, options = {}) ⇒ Object
25 26 27 28 29 |
# File 'lib/neuron/navigation.rb', line 25 def page_title(title = nil, = {}) = .merge() = .merge(default: (title, )) @page_title ||= title.try(:to_s) || view.t('.title', ) end |