Class: SchemaPlus::Views::SchemaDump::View

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

Overview

quacks like a SchemaMonkey Dump::Table

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#definitionObject

Returns the value of attribute definition

Returns:

  • (Object)

    the current value of definition



7
8
9
# File 'lib/schema_plus/views/schema_dump.rb', line 7

def definition
  @definition
end

#indexesObject

Returns the value of attribute indexes

Returns:

  • (Object)

    the current value of indexes



7
8
9
# File 'lib/schema_plus/views/schema_dump.rb', line 7

def indexes
  @indexes
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



7
8
9
# File 'lib/schema_plus/views/schema_dump.rb', line 7

def name
  @name
end

#view_typeObject

Returns the value of attribute view_type

Returns:

  • (Object)

    the current value of view_type



7
8
9
# File 'lib/schema_plus/views/schema_dump.rb', line 7

def view_type
  @view_type
end

Instance Method Details

#assemble(stream) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/schema_plus/views/schema_dump.rb', line 8

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
  stream.puts

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