Class: AwesomeTranslations::Handlers

Inherits:
Object
  • Object
show all
Defined in:
lib/awesome_translations/handlers.rb

Defined Under Namespace

Classes: BaseHandler, DeviseHandler, FileHandler, ModelHandler, RailsHandler, SimpleFormHandler, ValidationsHandler, WillPaginateHandler

Class Method Summary collapse

Class Method Details

.listObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/awesome_translations/handlers.rb', line 4

def self.list
  unless @handlers
    @handlers = []

    Dir.foreach("#{File.dirname(__FILE__)}/handlers") do |file|
      match = file.match(/\A(.+)_handler\.rb\Z/)
      next unless match

      const_name_snake = "#{match[1]}_handler"
      next if const_name_snake == "base_handler"

      const_name_camel = StringCases.snake_to_camel(const_name_snake)

      handler = AwesomeTranslations::Handler.new(
        id: const_name_snake,
        const_name: const_name_camel,
        name: const_name_camel
      )

      @handlers << handler if handler.instance.enabled?
    end
  end

  @handlers
end