Sha256: f8b729d47589eeb8f5fad198d9e08eda436c4af1f67d07ec06730f293329ca81

Contents?: true

Size: 750 Bytes

Versions: 2

Compression:

Stored size: 750 Bytes

Contents

# frozen_string_literal: true

module WCC::Blogs
  class Metadata
    extend WCC::Blogs::Utils

    attr_reader :raw

    def initialize(raw)
      @raw = raw
    end

    define_camelcase_alias(
      'id',
      'canonical_link',
      'meta_description',
      'meta_flag'
    ) do |camelcase|
      raw[camelcase]
    end

    define_camelcase_alias('meta_keywords') do |camelcase|
      keywords = raw[camelcase] || []

      # Currently the json looks like this:
      # "metaKeywords": {
      #   "metaKeywords": "regeneration, recovery"
      # },
      # TODO: make it like this - "metaKeywords": "regeneration, recovery"
      keywords = keywords[camelcase] if keywords.is_a?(Hash) && keywords[camelcase]

      keywords
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wcc-blogs-client-0.3.2 lib/wcc/blogs/metadata.rb
wcc-blogs-client-0.3.1 lib/wcc/blogs/metadata.rb