Sha256: bd1d6948dc1735c6ff3f3cd9e6bd8326b683f480661eaead06612aa226889896

Contents?: true

Size: 683 Bytes

Versions: 7

Compression:

Stored size: 683 Bytes

Contents

module Contentful
  # Utility methods used by the contentful gem
  module Support
    class << self
      # Transforms CamelCase into snake_case (taken from zucker)
      #
      # @param [String] object camelCaseName
      #
      # @return [String] snake_case_name
      def snakify(object)
        snake = String(object).gsub(/(?<!^)[A-Z]/) { "_#{$&}" }
        snake.downcase
      end

      # Returns true if resource is localized
      #
      # @return [Boolean]
      def localized?(value)
        return false unless value.is_a? ::Hash
        value.keys.any? { |possible_locale| Contentful::Constants::KNOWN_LOCALES.include?(possible_locale) }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
contentful-1.2.2 lib/contentful/support.rb
contentful-1.2.1 lib/contentful/support.rb
contentful-1.2.0 lib/contentful/support.rb
contentful-1.1.1 lib/contentful/support.rb
contentful-1.1.0 lib/contentful/support.rb
contentful-1.0.2 lib/contentful/support.rb
contentful-1.0.1 lib/contentful/support.rb