Class: Releaf::ControllerDefinition
- Inherits:
-
Object
- Object
- Releaf::ControllerDefinition
- Defined in:
- app/lib/releaf/controller_definition.rb
Instance Attribute Summary collapse
-
#controller_name ⇒ Object
Returns the value of attribute controller_name.
-
#helper ⇒ Object
Returns the value of attribute helper.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #group? ⇒ Boolean
-
#initialize(options) ⇒ ControllerDefinition
constructor
A new instance of ControllerDefinition.
- #localized_name ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(options) ⇒ ControllerDefinition
Returns a new instance of ControllerDefinition.
8 9 10 11 12 13 14 |
# File 'app/lib/releaf/controller_definition.rb', line 8 def initialize() = {controller: } if .is_a? String [:name] ||= [:controller] self.name = [:name] self.controller_name = [:controller] self.helper = "#{[:helper]}_path" if [:helper] end |
Instance Attribute Details
#controller_name ⇒ Object
Returns the value of attribute controller_name.
2 3 4 |
# File 'app/lib/releaf/controller_definition.rb', line 2 def controller_name @controller_name end |
#helper ⇒ Object
Returns the value of attribute helper.
2 3 4 |
# File 'app/lib/releaf/controller_definition.rb', line 2 def helper @helper end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'app/lib/releaf/controller_definition.rb', line 2 def name @name end |
Class Method Details
.for(controller_name) ⇒ Object
4 5 6 |
# File 'app/lib/releaf/controller_definition.rb', line 4 def self.for(controller_name) Releaf.application.config.controllers[controller_name] end |
Instance Method Details
#group? ⇒ Boolean
16 17 18 |
# File 'app/lib/releaf/controller_definition.rb', line 16 def group? false end |
#localized_name ⇒ Object
20 21 22 |
# File 'app/lib/releaf/controller_definition.rb', line 20 def localized_name I18n.t(name, scope: "admin.controllers") end |
#path ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/lib/releaf/controller_definition.rb', line 24 def path if helper Rails.application.routes.url_helpers.send(helper) else Rails.application.routes.url_helpers.url_for(action: :index, controller: controller_name, only_path: true) end end |