Sha256: 06d976407ef22d7d34fb7132baa70e09fb1e1918ae9c95eec543fc461aeab71f
Contents?: true
Size: 606 Bytes
Versions: 1
Compression:
Stored size: 606 Bytes
Contents
# frozen_string_literal: true module WCC::Contentful::Helpers extend self def content_type_from_raw(value) case value.dig('sys', 'type') when 'Entry' value.dig('sys', 'contentType', 'sys', 'id') when 'Asset' 'Asset' else raise ArgumentError, "Unknown content type '#{value.dig('sys', 'type') || 'null'}'" end end def constant_from_content_type(content_type) content_type.camelize.gsub(/[^_a-zA-Z0-9]/, '_') end def shared_prefix(string_array) string_array.reduce do |l, s| l = l.chop while l != s[0...l.length] l end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wcc-contentful-0.1.0 | lib/wcc/contentful/helpers.rb |