Class: PgDiff::View
- Inherits:
-
Object
- Object
- PgDiff::View
- Defined in:
- lib/view.rb
Instance Attribute Summary collapse
-
#def ⇒ Object
readonly
Returns the value of attribute def.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #definition ⇒ Object
-
#initialize(conn, sch, relname) ⇒ View
constructor
A new instance of View.
Constructor Details
#initialize(conn, sch, relname) ⇒ View
Returns a new instance of View.
5 6 7 8 9 10 11 12 |
# File 'lib/view.rb', line 5 def initialize(conn, sch, relname) @name = "#{sch}.#{relname}" view_qery = <<-EOT SELECT pg_catalog.pg_get_viewdef('#{@name}'::regclass, true) EOT tuple = conn.query(view_qery).first @def = tuple['pg_get_viewdef'] end |
Instance Attribute Details
#def ⇒ Object (readonly)
Returns the value of attribute def.
3 4 5 |
# File 'lib/view.rb', line 3 def def @def end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/view.rb', line 3 def name @name end |
Instance Method Details
#definition ⇒ Object
14 15 16 |
# File 'lib/view.rb', line 14 def definition "CREATE VIEW #{@name} AS #{@def}" end |