Sha256: 865070c954a12c3b1b5d0860453daaf54a163eee89c8c06dfcaca4b04693fdae

Contents?: true

Size: 729 Bytes

Versions: 1

Compression:

Stored size: 729 Bytes

Contents

class AwesomeTranslations::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"
    const_name_camel = StringCases.snake_to_camel(const_name_snake)

    autoload const_name_camel.to_sym, "#{File.dirname(__FILE__)}/handlers/#{const_name_snake}"

    unless const_name_snake == "base_handler"
      @handlers << AwesomeTranslations::Handler.new(
        id: const_name_snake,
        const_name: const_name_camel,
        name: const_name_camel
      )
    end
  end

  @handlers = @handlers.select { |handler| handler.instance.enabled? }

  def self.list
    @handlers
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
awesome_translations-0.0.24 lib/awesome_translations/handlers.rb