Sha256: cbd45dc12aeb171d67eb1ef89467338f66606372e7b7b0769f0cd5ff137b6224
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
module Contentful module Management module Resource # Adds metadata logic for [Resource] classes module Metadata # Returns the metadata hash # # @return [Hash] Metadata def metadata @metadata end # @private def initialize(object = nil, *) super @metadata = {} extract_metadata_from_object! object if object end # @private def inspect(info = nil) if metadata.empty? super(info) else super("#{info} @metadata=#{metadata.inspect}") end end private def extract_metadata_from_object!(object) return unless object.key?('metadata') object['metadata'].each do |key, value| @metadata[key.to_sym] = if key == 'tags' coerce_tags(value) else value end end end def coerce_tags(tags) tags.map { |tag| Contentful::Management::Link.new(tag) } end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
contentful-management-2.13.1 | lib/contentful/management/resource/metadata.rb |