Module: Kirei::Helpers
- Extended by:
- T::Sig
- Defined in:
- lib/kirei/helpers.rb
Class Method Summary collapse
- .deep_stringify_keys(object) ⇒ Object
- .deep_stringify_keys!(object) ⇒ Object
- .deep_symbolize_keys(object) ⇒ Object
- .deep_symbolize_keys!(object) ⇒ Object
- .underscore(string) ⇒ Object
Class Method Details
.deep_stringify_keys(object) ⇒ Object
21 22 23 |
# File 'lib/kirei/helpers.rb', line 21 def deep_stringify_keys(object) deep_transform_keys(object) { _1.to_s rescue _1 } # rubocop:disable Style/RescueModifier end |
.deep_stringify_keys!(object) ⇒ Object
26 27 28 |
# File 'lib/kirei/helpers.rb', line 26 def deep_stringify_keys!(object) deep_transform_keys!(object) { _1.to_s rescue _1 } # rubocop:disable Style/RescueModifier end |
.deep_symbolize_keys(object) ⇒ Object
31 32 33 |
# File 'lib/kirei/helpers.rb', line 31 def deep_symbolize_keys(object) deep_transform_keys(object) { _1.to_sym rescue _1 } # rubocop:disable Style/RescueModifier end |
.deep_symbolize_keys!(object) ⇒ Object
36 37 38 |
# File 'lib/kirei/helpers.rb', line 36 def deep_symbolize_keys!(object) deep_transform_keys!(object) { _1.to_sym rescue _1 } # rubocop:disable Style/RescueModifier end |
.underscore(string) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/kirei/helpers.rb', line 11 def underscore(string) string.gsub!(/([A-Z])(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) do T.must(::Regexp.last_match(1) || ::Regexp.last_match(2)) << "_" end string.tr!("-", "_") string.downcase! string end |