Module: AutoC::Composite::Decorator
- Defined in:
- lib/autoc/composite.rb
Constant Summary collapse
- CAMEL_CASE =
Pluggable CamelCase identifier decorator
-> (type, symbol, abbreviate: false, **kws) { id = symbol.to_s.sub(/[!?]$/, '') # Strip trailing !? _ = # Check for leading underscore if /^(_+)(.*)/ =~ id id = Regexp.last_match(2) # Chop leading underscore true else false end id = id[0] if abbreviate # Convert _separated_names to the CamelCase id = type.prefix + id.split('_').collect{ |s| s[0].upcase << s[1..-1] }.join # Carry over the method name's leading underscore only if the prefix is not in turn underscored _ && !type.prefix.start_with?('_') ? Regexp.last_match(1) + id : id }
- SNAKE_CASE =
Pluggable _snake_case identifier decorator
-> (type, symbol, abbreviate: false, **kws) { id = symbol.to_s.sub(/[!?]$/, '') # Strip trailing !? # Check for leading underscore _ = if /^(_+)(.*)/ =~ id id = Regexp.last_match(2) true else false end id = abbreviate ? "#{type.prefix}#{id[0]}" : "#{type.prefix}_#{id}" # Carry over the method name's leading underscore only if the prefix is not in turn underscored _ && !type.prefix.start_with?('_') ? Regexp.last_match(1) + id : id }