Sha256: 5de27445a361335c1d784697b63ed566700e8193e80226970bdadf7b8d0cf084

Contents?: true

Size: 585 Bytes

Versions: 2

Compression:

Stored size: 585 Bytes

Contents

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

    def drop_view(*args)
      reversible do |dir|
        dir.up { _drop_view(*args) }
        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

2 entries across 2 versions & 1 rubygems

Version Path
rein-3.1.0 lib/rein/view.rb
rein-3.0.0 lib/rein/view.rb