Sha256: ce9d4bdc7aa8c9be637664385de39aea5c066241291bfdc3dff5f20786c569d1

Contents?: true

Size: 820 Bytes

Versions: 6

Compression:

Stored size: 820 Bytes

Contents

module CouchMigrate
  class BaseExecuter
    def initialize(enabled, str, filename = "")
      raise "'enabled' argument must be an Array of symbols (such as [:up, :down] or []" unless enabled.is_a?(Array)
      @migration_str = str
      @enabled = enabled
      @filename = filename
      self
    end

    def go
      Namespaced.module_eval(<<-EOS, __FILE__, __LINE__ + 1)
        def self.up
          yield if #{@enabled.include?(:up)}
        end

        def self.down
          yield if #{@enabled.include?(:down)}
        end

        # convenience method for migration files to use
        def self.use_couchrest_model
          require 'couch_migrate/couchrest_model/extend.rb'
        end

      EOS

      Namespaced.module_eval(@migration_str, @filename)
    end

    module Namespaced
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
couch-migrate-2.0.2 lib/couch_migrate/base_executer.rb
couch-migrate-1.1.3 lib/couch_migrate/base_executer.rb
couch-migrate-1.1.2 lib/couch_migrate/base_executer.rb
couch-migrate-1.1.1 lib/couch_migrate/base_executer.rb
couch-migrate-1.1.0 lib/couch_migrate/base_executer.rb
couch-migrate-1.0.0 lib/couch_migrate/base_executer.rb