Class: Releaf::ControllerDefinition

Inherits:
Object
  • Object
show all
Defined in:
app/lib/releaf/controller_definition.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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(options)
  options = {controller: options} if options.is_a? String
  options[:name] ||= options[:controller]
  self.name = options[:name]
  self.controller_name = options[:controller]
  self.helper = "#{options[:helper]}_path" if options[:helper]
end

Instance Attribute Details

#controller_nameObject

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

#helperObject

Returns the value of attribute helper


2
3
4
# File 'app/lib/releaf/controller_definition.rb', line 2

def helper
  @helper
end

#nameObject

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

Returns:

  • (Boolean)

16
17
18
# File 'app/lib/releaf/controller_definition.rb', line 16

def group?
  false
end

#localized_nameObject


20
21
22
# File 'app/lib/releaf/controller_definition.rb', line 20

def localized_name
  I18n.t(name, scope: "admin.controllers")
end

#pathObject


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