Class: PGAssets::PGView

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
LoadableAsset
Defined in:
lib/pg_assets/models/pg_view.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.by_name(name) ⇒ Object



13
14
15
# File 'lib/pg_assets/models/pg_view.rb', line 13

def self.by_name(name)
  where(viewname: name.to_s)
end

Instance Method Details

#identityObject



17
18
19
# File 'lib/pg_assets/models/pg_view.rb', line 17

def identity
  schemaname + '.' + viewname
end

#sql_for_reinstall(defn = cached_defn) ⇒ Object



25
26
27
# File 'lib/pg_assets/models/pg_view.rb', line 25

def sql_for_reinstall(defn=cached_defn)
  sql = "CREATE OR REPLACE VIEW #{schemaname}.#{viewname} AS #{defn}"
end

#sql_for_removeObject



21
22
23
# File 'lib/pg_assets/models/pg_view.rb', line 21

def sql_for_remove
  sql = "DROP VIEW IF EXISTS #{schemaname}.#{viewname}"
end