Sha256: 338f044e9e150246d570471bb71d914b9e497225de32f42be26117d6b95b4362

Contents?: true

Size: 916 Bytes

Versions: 5

Compression:

Stored size: 916 Bytes

Contents

begin
  require 'active_support/inflector'
  require 'active_support/core_ext/module/delegation'
rescue LoadError
  raise ::Alba::Error, 'To use default inflector, please install `ActiveSupport` gem.'
end

module Alba
  # This module has two purposes.
  # One is that we require `active_support/inflector` in this module so that we don't do that all over the place.
  # Another is that `ActiveSupport::Inflector` doesn't have `camelize_lower` method that we want it to have, so this module works as an adapter.
  module DefaultInflector
    class << self
      delegate :camelize, :dasherize, :underscore, :classify, :demodulize, :pluralize, to: ActiveSupport::Inflector
    end

    # Camelizes a key, 1st letter lowercase
    #
    # @param key [String] key to be camelized
    # @return [String] camelized key
    def self.camelize_lower(key)
      ActiveSupport::Inflector.camelize(key, false)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alba-2.3.0 lib/alba/default_inflector.rb
alba-2.2.0 lib/alba/default_inflector.rb
alba-2.1.0 lib/alba/default_inflector.rb
alba-2.0.1 lib/alba/default_inflector.rb
alba-2.0.0 lib/alba/default_inflector.rb