Sha256: c85fbd84e4c0e8ac2fc55403887130bae12f4794e41163b66a4a4e49f17ad8ca

Contents?: true

Size: 788 Bytes

Versions: 23

Compression:

Stored size: 788 Bytes

Contents

class Releaf::ControllerDefinition
  attr_accessor :name, :controller_name, :helper

  def self.for(controller_name)
    Releaf.application.config.controllers[controller_name]
  end

  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

  def group?
    false
  end

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

  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
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
releaf-core-3.1.0 lib/releaf/controller_definition.rb
releaf-core-3.0.3 lib/releaf/controller_definition.rb
releaf-core-3.0.2 lib/releaf/controller_definition.rb
releaf-core-3.0.1 lib/releaf/controller_definition.rb
releaf-core-3.0.0 lib/releaf/controller_definition.rb
releaf-core-2.2.1 app/lib/releaf/controller_definition.rb
releaf-core-2.2.0 app/lib/releaf/controller_definition.rb
releaf-core-2.1.2 app/lib/releaf/controller_definition.rb
releaf-core-2.1.1 app/lib/releaf/controller_definition.rb
releaf-core-2.1.0 app/lib/releaf/controller_definition.rb
releaf-core-2.0.1 app/lib/releaf/controller_definition.rb
releaf-core-2.0.0 app/lib/releaf/controller_definition.rb
releaf-core-1.1.22 app/lib/releaf/controller_definition.rb
releaf-core-1.1.21 app/lib/releaf/controller_definition.rb
releaf-core-1.1.20 app/lib/releaf/controller_definition.rb
releaf-core-1.1.19 app/lib/releaf/controller_definition.rb
releaf-core-1.1.18 app/lib/releaf/controller_definition.rb
releaf-core-1.1.17 app/lib/releaf/controller_definition.rb
releaf-core-1.1.16 app/lib/releaf/controller_definition.rb
releaf-core-1.1.15 app/lib/releaf/controller_definition.rb