Class: PageMeta::Naming
- Inherits:
-
Object
- Object
- PageMeta::Naming
- Defined in:
- lib/page_meta/naming.rb
Instance Method Summary collapse
- #action ⇒ Object
-
#controller ⇒ Object
Normalize the controller name.
-
#initialize(controller) ⇒ Naming
constructor
A new instance of Naming.
Constructor Details
#initialize(controller) ⇒ Naming
Returns a new instance of Naming.
5 6 7 |
# File 'lib/page_meta/naming.rb', line 5 def initialize(controller) @_controller = controller end |
Instance Method Details
#action ⇒ Object
9 10 11 |
# File 'lib/page_meta/naming.rb', line 9 def action (@action ||= Action.new(@_controller.action_name)).to_s end |
#controller ⇒ Object
Normalize the controller name. Converts ‘PagesController` into `pages` and `Admin::PagesController` into `admin.pages`.
16 17 18 19 20 21 22 23 |
# File 'lib/page_meta/naming.rb', line 16 def controller @controller ||= @_controller .class .name .underscore .gsub("_controller", "") .tr("/", ".") end |