Class: Consyncful::ItemMapper
- Inherits:
-
Object
- Object
- Consyncful::ItemMapper
- Defined in:
- lib/consyncful/item_mapper.rb
Instance Method Summary collapse
- #deletion? ⇒ Boolean
- #id ⇒ Object
-
#initialize(item) ⇒ ItemMapper
constructor
A new instance of ItemMapper.
- #mapped_fields(locale) ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(item) ⇒ ItemMapper
Returns a new instance of ItemMapper.
5 6 7 |
# File 'lib/consyncful/item_mapper.rb', line 5 def initialize(item) @item = item end |
Instance Method Details
#deletion? ⇒ Boolean
9 10 11 |
# File 'lib/consyncful/item_mapper.rb', line 9 def deletion? @item.is_a?(Contentful::DeletedEntry) || @item.is_a?(Contentful::DeletedAsset) end |
#id ⇒ Object
21 22 23 |
# File 'lib/consyncful/item_mapper.rb', line 21 def id @item.id end |
#mapped_fields(locale) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/consyncful/item_mapper.rb', line 25 def mapped_fields(locale) fields = generic_fields @item.fields_with_locales.each do |field, value_with_locales| value = value_with_locales[locale.to_sym] next if value.is_a? Contentful::File # it is special assign_field(fields, field, value) end fields[:file] = raw_file(locale) if type == 'asset' fields end |
#type ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/consyncful/item_mapper.rb', line 13 def type if @item.type == 'Entry' @item.content_type.id elsif @item.type == 'Asset' 'asset' end end |