Sha256: da3322340ad26854adc524178bfcdfcc932f1af946605b25543d1d3e6496b042
Contents?: true
Size: 977 Bytes
Versions: 2
Compression:
Stored size: 977 Bytes
Contents
module Alba # This module creates key transform functions module KeyTransformFactory class << self # Create key transform function for given transform_type # # @param transform_type [Symbol] transform type # @return [Proc] transform function # @raise [Alba::Error] when transform_type is not supported def create(transform_type) case transform_type when :camel ->(key) { _inflector.camelize(key) } when :lower_camel ->(key) { _inflector.camelize_lower(key) } when :dash ->(key) { _inflector.dasherize(key) } else raise ::Alba::Error, "Unknown transform_type: #{transform_type}. Supported transform_type are :camel, :lower_camel and :dash." end end private def _inflector Alba.inflector || begin require_relative './default_inflector' Alba::DefaultInflector end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
alba-1.5.0 | lib/alba/key_transform_factory.rb |
alba-1.4.0 | lib/alba/key_transform_factory.rb |