Sha256: d702caf6401f6664282e04dd08efe770476f9fc1054d6e4a929fd424567a4d41
Contents?: true
Size: 1.59 KB
Versions: 5
Compression:
Stored size: 1.59 KB
Contents
module Locomotive::Wagon class PushBaseCommand < Struct.new(:api_client, :steam_services, :content_assets_pusher) extend Forwardable def_delegators :steam_services, :current_site, :locale, :repositories def self.push(api_client, steam_services, content_assets_pusher) new(api_client, steam_services, content_assets_pusher).push end def push instrument do instrument :start self._push_with_timezone instrument :done end end def _push_with_timezone Time.use_zone(current_site.try(:timezone)) do _push end end def _push entities.each do |entity| decorated = decorate(entity) begin instrument :persist, label: label_for(decorated) persist(decorated) instrument :persist_with_success rescue SkipPersistingException => e instrument :skip_persisting # rescue Exception => e # instrument :persist_with_error, message: e.message end end end def instrument(action = nil, payload = {}, &block) name = ['wagon.push', [*action]].flatten.compact.join('.') ActiveSupport::Notifications.instrument(name, { name: resource_name }.merge(payload), &block) end def resource_name self.class.name[/::Push(\w+)Command$/, 1].underscore end def default_locale current_site.default_locale end def locales current_site.locales end def path File.expand_path(repositories.adapter.options[:path]) end class SkipPersistingException < Exception end end end
Version data entries
5 entries across 5 versions & 1 rubygems