Module: Contentful::Resource::Fields

Included in:
Entry
Defined in:
lib/contentful/resource/fields.rb

Overview

Include this module into your Resource class to enable it to deal with entry fields (but not asset fields)

It depends on system properties being available

Defined Under Namespace

Modules: ClassMethods

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) included(base)



34
35
36
# File 'lib/contentful/resource/fields.rb', line 34

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

Instance Method Details

- (Object) fields

Returns all fields of the asset



9
10
11
# File 'lib/contentful/resource/fields.rb', line 9

def fields
  @fields[locale]
end

- (Object) initialize(object)



13
14
15
16
17
# File 'lib/contentful/resource/fields.rb', line 13

def initialize(object, *)
  super
  @fields = {}
  @fields[locale] = extract_from_object object["fields"], :fields
end

- (Object) inspect(info = nil)



19
20
21
22
23
24
25
# File 'lib/contentful/resource/fields.rb', line 19

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