Sha256: 53c7de3f5cfd409765d68f347aa2a1a0ea7a3ef9c1a8ca11bf5f3facf1fb09cc

Contents?: true

Size: 823 Bytes

Versions: 14

Compression:

Stored size: 823 Bytes

Contents

require 'singleton'

module RailsConnector
  module Migrations
    class WorkspaceLock
      include Singleton

      def validate(workspace)
        unless exists? && workspace.revision_id == File.read(filename)
          raise RailsConnectorError.new("Migration Workspace already exists. Please make sure to \
            publish or discard any changes in the '#{workspace.id}' workspace.")
        end
      end

      def write(workspace)
        File.open(filename, 'w') do |file|
          file.write(workspace.revision_id)
        end
      end

      def remove
        if exists?
          File.delete(filename)
        end
      end

      def exists?
        File.exists?(filename)
      end

      private

      def filename
        File.join(Rails.root, 'tmp/migration_store.lock')
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
infopark_cloud_connector-6.9.4 lib/rails_connector/migrations/workspace_lock.rb
infopark_cloud_connector-6.9.3.1.36404185 lib/rails_connector/migrations/workspace_lock.rb
infopark_cloud_connector-6.9.2.1.125136549 lib/rails_connector/migrations/workspace_lock.rb
infopark_cloud_connector-6.9.1.3.22208381 lib/rails_connector/migrations/workspace_lock.rb
infopark_cloud_connector-6.9.0.3.197272233 lib/rails_connector/migrations/workspace_lock.rb
infopark_cloud_connector-6.8.3.174.51542603 lib/rails_connector/migrations/workspace_lock.rb
infopark_cloud_connector-6.8.3.115.227021242 lib/rails_connector/migrations/workspace_lock.rb
infopark_cloud_connector-6.8.3.73.75172665 lib/rails_connector/migrations/workspace_lock.rb
infopark_cloud_connector-6.8.3.2.153416031 lib/rails_connector/migrations/workspace_lock.rb
infopark_cloud_connector-6.8.3.67.110847540 lib/rails_connector/migrations/workspace_lock.rb
infopark_cloud_connector-6.8.3.1.23895778 lib/rails_connector/migrations/workspace_lock.rb
infopark_cloud_connector-6.8.2.36.82613853 lib/rails_connector/migrations/workspace_lock.rb
infopark_cloud_connector-6.8.2.7.128454143 lib/rails_connector/migrations/workspace_lock.rb
infopark_cloud_connector-6.8.1.26.236500544 lib/rails_connector/migrations/workspace_lock.rb