Sha256: 23cb2d99d672388ec5a11eead74d09316829efaf2ae927d2f7434ff7a81e27b2

Contents?: true

Size: 1.04 KB

Versions: 10

Compression:

Stored size: 1.04 KB

Contents

module Locomotive::Wagon

  class PushSiteCommand < PushBaseCommand

    def entities
      [repositories.site.first]
    end

    def decorate(entity)
      UpdateSiteDecorator.new(entity, default_locale, path, content_assets_pusher)
    end

    def persist(decorated_entity)
      _attributes = decorated_entity.to_hash

      # push the picture only if there is no existing remote picture
      _attributes.delete(:picture) if remote_site['picture_url'].present?

      # timezone can be pushed with the -d option
      _attributes.delete(:timezone) unless with_data?

      # push the locales as long as there is no content on the remote site yet
      _attributes.delete(:locales) if remote_site.edited?

      _attributes.delete(:metafields) unless with_data?

      _attributes.delete(:sections_content) unless with_data?

      if _attributes.present?
        api_client.current_site.update(_attributes)
      else
        raise SkipPersistingException.new
      end
    end

    def label_for(decorated_entity)
      decorated_entity.name
    end

  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
locomotivecms_wagon-3.2.0.alpha2 lib/locomotive/wagon/commands/push_sub_commands/push_site_command.rb
locomotivecms_wagon-3.2.0.alpha1 lib/locomotive/wagon/commands/push_sub_commands/push_site_command.rb
locomotivecms_wagon-3.1.1 lib/locomotive/wagon/commands/push_sub_commands/push_site_command.rb
locomotivecms_wagon-3.1.0 lib/locomotive/wagon/commands/push_sub_commands/push_site_command.rb
locomotivecms_wagon-3.1.0.beta1 lib/locomotive/wagon/commands/push_sub_commands/push_site_command.rb
locomotivecms_wagon-3.0.5 lib/locomotive/wagon/commands/push_sub_commands/push_site_command.rb
locomotivecms_wagon-3.0.4 lib/locomotive/wagon/commands/push_sub_commands/push_site_command.rb
locomotivecms_wagon-3.0.3 lib/locomotive/wagon/commands/push_sub_commands/push_site_command.rb
locomotivecms_wagon-3.0.2 lib/locomotive/wagon/commands/push_sub_commands/push_site_command.rb
locomotivecms_wagon-3.0.0 lib/locomotive/wagon/commands/push_sub_commands/push_site_command.rb