5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/models/iron/entry/presentable.rb', line 5
def attributes
locale = Iron::Current.locale || Iron::Locale.default
Rails.cache.fetch("#{cache_key_with_version}/#{locale.code}/attributes") do
result = OpenStruct.new(id: id)
result._metadata = OpenStruct.new(
locale: locale,
web: OpenStruct.new(
title: web_title,
path: path
)
)
content_type.field_definitions.each do |field_definition|
field = find_field_for_presentation(field_definition, locale)
result[field_definition.handle] = if field.present?
field.value
elsif field_definition.is_a?(FieldDefinitions::BlockList)
[]
else
nil
end
end
result
end
end
|