Sha256: 093353af6718c09566ef51065725fe26b99a3227278fc290920fcba9f2b26358
Contents?: true
Size: 1.53 KB
Versions: 18
Compression:
Stored size: 1.53 KB
Contents
module Contentful module Management module Resource # Adds the feature to have system properties to a Resource. module SystemProperties # @private # Coercions for System Properties to native types SYS_COERCIONS = { type: :string, id: :string, space: nil, contentType: nil, linkType: :string, revision: :integer, createdAt: :date, updatedAt: :date, locale: :string }.freeze attr_reader :sys # @private def initialize(object = { 'sys' => nil }, *) super object ||= { 'sys' => nil } @sys = extract_from_object object['sys'], :sys end # @private def inspect(info = nil) if sys.empty? super(info) else super("#{info} @sys=#{sys.inspect}") end end # @private module ClassMethods # @private def sys_coercions SYS_COERCIONS end end # @private def self.included(base) base.extend(ClassMethods) base.sys_coercions.keys.each do |name| accessor_name = Contentful::Management::Support.snakify(name) base.send :define_method, accessor_name do sys[name.to_sym] end base.send :define_method, "#{accessor_name}=" do |value| sys[name.to_sym] = value end end end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems