lib/wcc/contentful/model_builder.rb in wcc-contentful-1.6.2 vs lib/wcc/contentful/model_builder.rb in wcc-contentful-1.7.0

- old
+ new

@@ -1,10 +1,11 @@ # frozen_string_literal: true require 'ostruct' require_relative './link' require_relative './sys' +require_relative './metadata' require_relative './rich_text' module WCC::Contentful class ModelBuilder include Helpers @@ -85,10 +86,14 @@ updated_at, raw.dig('sys', 'revision'), OpenStruct.new(context).freeze ) + @metadata = WCC::Contentful::Metadata.new( + raw['metadata'] + ) + typedef.fields.each_value do |f| raw_value = raw.dig('fields', f.name) if raw_value.present? case f.type @@ -118,9 +123,10 @@ instance_variable_set("@#{f.name}", raw_value) end end attr_reader :sys + attr_reader :metadata attr_reader :raw delegate :id, to: :sys delegate :created_at, to: :sys delegate :updated_at, to: :sys