Sha256: f6c4540ce20ba969c5d997d77c139c5d150ac76ad108ba4718b82665c59ced47

Contents?: true

Size: 594 Bytes

Versions: 3

Compression:

Stored size: 594 Bytes

Contents

module Rein
  # This module contains methods for creating/dropping views.
  module View
    def create_view(*args)
      reversible do |dir|
        dir.up do _create_view(*args) end
        dir.down { _drop_view(*args) }
      end
    end

    def drop_view(*args)
      reversible do |dir|
        dir.up do _drop_view(*args) end
        dir.down { _create_view(*args) }
      end
    end

    private

    def _create_view(view_name, sql)
      execute("CREATE VIEW #{view_name} AS #{sql}")
    end

    def _drop_view(view_name, *)
      execute("DROP VIEW #{view_name}")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rein-3.5.0 lib/rein/view.rb
rein-3.4.0 lib/rein/view.rb
rein-3.3.0 lib/rein/view.rb