Module: Contentful::Resource::SystemProperties

Included in:
Array, Asset, ContentType, Entry, Link, Space
Defined in:
lib/contentful/resource/system_properties.rb

Overview

Adds the feature to have system properties to a Resource.

Defined Under Namespace

Modules: ClassMethods

Constant Summary

SYS_COERCIONS =
{
  type: :string,
  id: :string,
  space: nil,
  contentType: nil,
  linkType: :string,
  revision: :integer,
  createdAt: :date,
  updatedAt: :date,
  locale: :string,
}

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) sys (readonly)

Returns the value of attribute sys



16
17
18
# File 'lib/contentful/resource/system_properties.rb', line 16

def sys
  @sys
end

Class Method Details

+ (Object) included(base)



37
38
39
40
41
42
43
44
45
# File 'lib/contentful/resource/system_properties.rb', line 37

def self.included(base)
  base.extend(ClassMethods)

  base.sys_coercions.keys.each{ |name|
    base.send :define_method, Contentful::Support.snakify(name) do
      sys[name.to_sym]
    end
  }
end

Instance Method Details

- (Object) initialize(object)



18
19
20
21
# File 'lib/contentful/resource/system_properties.rb', line 18

def initialize(object, *)
  super
  @sys = extract_from_object object["sys"], :sys
end

- (Object) inspect(info = nil)



23
24
25
26
27
28
29
# File 'lib/contentful/resource/system_properties.rb', line 23

def inspect(info = nil)
  if sys.empty?
    super(info)
  else
    super("#{info} @sys=#{sys.inspect}")
  end
end