Module: Slices::HasAttachments::PageInstanceMethods

Included in:
Page
Defined in:
lib/slices/has_attachments.rb

Instance Method Summary collapse

Instance Method Details

#attachment_assetsObject



48
49
50
51
52
53
54
55
56
# File 'lib/slices/has_attachments.rb', line 48

def attachment_assets
  attachment_asset_ids.inject([]) do |memo, asset_id|
    begin
      memo << ::Asset.find(asset_id)
    rescue Mongoid::Errors::DocumentNotFound
    end
    memo
  end
end

#slice_attachment_asset_idsObject Also known as: attachment_asset_ids



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/slices/has_attachments.rb', line 58

def slice_attachment_asset_ids
  [].tap do |asset_ids|
    self.class.slice_embeds.each do |slice_embed|
      slices_for(slice_embed).each do |slice|
        if slice.respond_to? :attachment_asset_ids
          asset_ids.concat slice.attachment_asset_ids
        end
      end
    end
  end
end