Class: Locomotive::Mounter::Writer::Api::SnippetsWriter

Inherits:
Base
  • Object
show all
Defined in:
lib/locomotive/mounter/writer/api/snippets_writer.rb

Overview

Push snippets to a remote LocomotiveCMS engine.

The force option is not used.

Instance Attribute Summary

Attributes inherited from Base

#mounting_point, #runner

Instance Method Summary collapse

Methods inherited from Base

#absolute_path, #data?, #each_locale, #get, #initialize, #path_to_file, #post, #put, #replace_content_assets!, #safe_attributes

Constructor Details

This class inherits a constructor from Locomotive::Mounter::Writer::Api::Base

Instance Method Details

#prepareObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/locomotive/mounter/writer/api/snippets_writer.rb', line 12

def prepare
  super

  # set the unique identifier to each local snippet
  self.get(:snippets, nil, true).each do |attributes|
    snippet = self.snippets[attributes['slug']]

    snippet._id = attributes['id'] if snippet
  end
end

#writeObject

Write all the snippets to the remote destination



24
25
26
27
28
29
30
# File 'lib/locomotive/mounter/writer/api/snippets_writer.rb', line 24

def write
  self.each_locale do |locale|
    self.output_locale

    self.snippets.values.each { |snippet| self.write_snippet(snippet) }
  end
end