Class: DRYParams::Naming
- Inherits:
-
Object
- Object
- DRYParams::Naming
- Defined in:
- lib/dryparams/naming.rb
Overview
The class returns the different names available for a given controller.
Instance Method Summary collapse
- #initialize(controller_instance) ⇒ self constructor
-
#klass ⇒ String
The model name associated to the controller.
-
#model ⇒ Class
The model class associated to the controller.
-
#object ⇒ String
The object name from the controller.
Constructor Details
#initialize(controller_instance) ⇒ self
9 10 11 |
# File 'lib/dryparams/naming.rb', line 9 def initialize(controller_instance) @controller = controller_instance end |
Instance Method Details
#klass ⇒ String
Returns the model name associated to the controller.
28 29 30 |
# File 'lib/dryparams/naming.rb', line 28 def klass @klass ||= @controller.controller_name.classify end |
#model ⇒ Class
Returns the model class associated to the controller.
14 15 16 17 18 19 20 |
# File 'lib/dryparams/naming.rb', line 14 def model @model ||= begin klass.constantize rescue NameError nil end end |
#object ⇒ String
Returns the object name from the controller.
23 24 25 |
# File 'lib/dryparams/naming.rb', line 23 def object @object ||= klass.downcase end |