Sha256: fa50a045216f1122b0536c08c90f2d184b380c1f0c1f3d2fe51a8124d2e1d6c2
Contents?: true
Size: 978 Bytes
Versions: 1
Compression:
Stored size: 978 Bytes
Contents
module Alba # This module creates key transform functions module KeyTransformFactory class << self # Create key transform function for given transform_type # # @params 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alba-1.3.0 | lib/alba/key_transform_factory.rb |