Class: Locomotive::Mounter::Writer::Api::SiteWriter

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

Instance Attribute Summary collapse

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!

Constructor Details

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

Instance Attribute Details

#remote_siteObject

Returns the value of attribute remote_site.



8
9
10
# File 'lib/locomotive/mounter/writer/api/site_writer.rb', line 8

def remote_site
  @remote_site
end

Instance Method Details

#prepareObject

Check if the site has to be created before.



11
12
13
14
15
# File 'lib/locomotive/mounter/writer/api/site_writer.rb', line 11

def prepare
  super

  self.fetch_site
end

#writeObject

Create the site if it does not exist



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/locomotive/mounter/writer/api/site_writer.rb', line 18

def write
  if self.site.persisted?
    self.check_locales! unless self.force? # requirements

    if self.force?
      self.update_site
    end
  else
    self.create_site
  end
end