Class: Titlezilla::Translator
- Inherits:
-
Object
- Object
- Titlezilla::Translator
- Defined in:
- lib/titlezilla/translator.rb
Instance Attribute Summary collapse
-
#action_name ⇒ Object
readonly
Returns the value of attribute action_name.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#controller_name ⇒ Object
readonly
Returns the value of attribute controller_name.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
Instance Method Summary collapse
- #application_title ⇒ Object
-
#initialize(controller_path, action_name, context = {}) ⇒ Translator
constructor
A new instance of Translator.
- #meta_title ⇒ Object
- #title(override = nil) ⇒ Object
Constructor Details
#initialize(controller_path, action_name, context = {}) ⇒ Translator
Returns a new instance of Translator.
7 8 9 10 11 |
# File 'lib/titlezilla/translator.rb', line 7 def initialize(controller_path, action_name, context = {}) @namespace, @controller_name = parse_namespace_and_controller_name(controller_path) @action_name = action_name.to_s.freeze @context = context end |
Instance Attribute Details
#action_name ⇒ Object (readonly)
Returns the value of attribute action_name.
5 6 7 |
# File 'lib/titlezilla/translator.rb', line 5 def action_name @action_name end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
5 6 7 |
# File 'lib/titlezilla/translator.rb', line 5 def context @context end |
#controller_name ⇒ Object (readonly)
Returns the value of attribute controller_name.
5 6 7 |
# File 'lib/titlezilla/translator.rb', line 5 def controller_name @controller_name end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
5 6 7 |
# File 'lib/titlezilla/translator.rb', line 5 def namespace @namespace end |
Instance Method Details
#application_title ⇒ Object
21 22 23 |
# File 'lib/titlezilla/translator.rb', line 21 def application_title @application_title ||= reverse_lookup('application') end |
#meta_title ⇒ Object
25 26 27 |
# File 'lib/titlezilla/translator.rb', line 25 def [title, application_title].compact.join(::Titlezilla.configuration.separator) end |
#title(override = nil) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/titlezilla/translator.rb', line 13 def title(override = nil) if !override @title ||= lookup(controller_name, map(action_name)) else @title = override end end |