Class: Titlezilla::Translator

Inherits:
Object
  • Object
show all
Defined in:
lib/titlezilla/translator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_nameObject (readonly)

Returns the value of attribute action_name.



5
6
7
# File 'lib/titlezilla/translator.rb', line 5

def action_name
  @action_name
end

#contextObject (readonly)

Returns the value of attribute context.



5
6
7
# File 'lib/titlezilla/translator.rb', line 5

def context
  @context
end

#controller_nameObject (readonly)

Returns the value of attribute controller_name.



5
6
7
# File 'lib/titlezilla/translator.rb', line 5

def controller_name
  @controller_name
end

#namespaceObject (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_titleObject



21
22
23
# File 'lib/titlezilla/translator.rb', line 21

def application_title
  @application_title ||= reverse_lookup('application')
end

#meta_titleObject



25
26
27
# File 'lib/titlezilla/translator.rb', line 25

def meta_title
  [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