Module: Dbee::Dsl::Inflectable
- Included in:
- Base
- Defined in:
- lib/dbee/dsl/inflectable.rb
Overview
Provides methods for dealing with naming grammar.
Instance Method Summary collapse
Instance Method Details
#constantize(value) ⇒ Object
14 15 16 |
# File 'lib/dbee/dsl/inflectable.rb', line 14 def constantize(value) value.is_a?(String) || value.is_a?(Symbol) ? Object.const_get(value) : value end |
#tableize(value) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/dbee/dsl/inflectable.rb', line 18 def tableize(value) value.split('::') .last .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') .downcase end |