Module: Contentful::Support
- Defined in:
- lib/contentful/support.rb
Overview
Utility methods used by the contentful gem
Class Method Summary collapse
-
.localized?(value) ⇒ Boolean
Returns true if resource is localized.
-
.snakify(object) ⇒ String
Transforms CamelCase into snake_case (taken from zucker).
Class Method Details
.localized?(value) ⇒ Boolean
Returns true if resource is localized
18 19 20 21 |
# File 'lib/contentful/support.rb', line 18 def localized?(value) return false unless value.is_a? ::Hash value.keys.any? { |possible_locale| Contentful::Constants::KNOWN_LOCALES.include?(possible_locale) } end |
.snakify(object) ⇒ String
Transforms CamelCase into snake_case (taken from zucker)
10 11 12 13 |
# File 'lib/contentful/support.rb', line 10 def snakify(object) snake = String(object).gsub(/(?<!^)[A-Z]/) { "_#{$&}" } snake.downcase end |