Class: SchemaPlus::Views::Middleware::Dumper::Tables::View

Inherits:
Object
  • Object
show all
Defined in:
lib/schema_plus/views/middleware.rb

Overview

quacks like a SchemaMonkey Dump::Table

Instance Method Summary collapse

Instance Method Details

#assemble(stream) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/schema_plus/views/middleware.rb', line 53

def assemble(stream)
  extra_options = ", materialized: true" if view_type == :materialized
  heredelim     = "END_VIEW_#{name.upcase}"
  stream.puts <<~ENDVIEW
    create_view "#{name}", <<-'#{heredelim}', :force => true#{extra_options}
      #{definition}
    #{heredelim}
  ENDVIEW

  indexes.each do |index|
    stream.write "add_index \"#{name}\", "
    index.assemble(stream)
    stream.puts ""
  end
end