Module: EasyTalk::NamingStrategies
- Defined in:
- lib/easy_talk/naming_strategies.rb
Constant Summary collapse
- IDENTITY =
lambda(&:to_sym)
- SNAKE_CASE =
->(property_name) { property_name.to_s.underscore.to_sym }
- CAMEL_CASE =
->(property_name) { property_name.to_s.tr('-', '_').camelize(:lower).to_sym }
- PASCAL_CASE =
->(property_name) { property_name.to_s.tr('-', '_').camelize.to_sym }
Class Method Summary collapse
Class Method Details
.derive_strategy(strategy) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/easy_talk/naming_strategies.rb', line 10 def self.derive_strategy(strategy) if strategy.is_a?(Symbol) "EasyTalk::NamingStrategies::#{strategy.to_s.upcase}".constantize elsif strategy.is_a?(Proc) strategy else raise ArgumentError, 'Invalid property naming strategy. Must be a Symbol or a Proc.' end end |