Sha256: e82daea7e114556c5eb4efb09999804784df78759ad46011e86e0f9924f2171e

Contents?: true

Size: 1.05 KB

Versions: 8

Compression:

Stored size: 1.05 KB

Contents

module Flexite
  class Diff
    class PushService
      def initialize(stage, url)
        @stage = stage
        @remote_diff = Diff.new(url)
        @state_digest = Flexite.state_digest
      end

      def call
        checksum = Flexite.cache.read("#{@state_digest}-#{@stage}-diff-checksum")
        Flexite.cache.delete_matched(Flexite.match_key("-#{@stage}-diff-checksum"))
        Flexite.cache.delete_matched(Flexite.match_key("-#{@stage}-show-diff"))


        if checksum.blank?
          return ActionService::Result.new(flash: { type: :warning, message: 'Settings were changed and difference should be revalidated' })
        end

        response = @remote_diff.apply({ token: Flexite.config.migration_token, stage: Flexite.config.stagename, checksum: checksum })

        if response[:error].blank?
          ActionService::Result.new(flash: { type: :success, message: response[:message] })
        else
          ActionService::Result.new(flash: { type: :danger, message: "#{response[:error]}, code: #{response[:code]}" })
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
flexite-0.0.25 app/services/flexite/diff/push_service.rb
flexite-0.0.24 app/services/flexite/diff/push_service.rb
flexite-0.0.23 app/services/flexite/diff/push_service.rb
flexite-0.0.22 app/services/flexite/diff/push_service.rb
flexite-0.0.21 app/services/flexite/diff/push_service.rb
flexite-0.0.20 app/services/flexite/diff/push_service.rb
flexite-0.0.19 app/services/flexite/diff/push_service.rb
flexite-0.0.18 app/services/flexite/diff/push_service.rb