Class: Scenic::View

Inherits:
Object
  • Object
show all
Defined in:
lib/scenic/view.rb

Overview

The in-memory representation of a view definition.

This object is used internally by adapters and the schema dumper and is not intended to be used by application code. It is documented here for use by adapter gems.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, definition:, materialized:) ⇒ View

Returns a new instance of View.

Parameters:

  • name (String)

    The name of the view.

  • definition (String)

    The SQL for the query that defines the view.

  • materialized (Boolean)

    true if the view is materialized.



30
31
32
33
34
# File 'lib/scenic/view.rb', line 30

def initialize(name:, definition:, materialized:)
  @name = name
  @definition = definition
  @materialized = materialized
end

Instance Attribute Details

#definitionString (readonly)

The SQL schema for the query that defines the view

Examples:

"SELECT name, email FROM users UNION SELECT name, email FROM contacts"

Returns:

  • (String)


19
20
21
# File 'lib/scenic/view.rb', line 19

def definition
  @definition
end

#materializedBoolean (readonly)

True if the view is materialized

Returns:

  • (Boolean)


23
24
25
# File 'lib/scenic/view.rb', line 23

def materialized
  @materialized
end

#nameString (readonly)

The name of the view

Returns:

  • (String)


12
13
14
# File 'lib/scenic/view.rb', line 12

def name
  @name
end

Instance Method Details

#escaped_definitionObject



54
55
56
# File 'lib/scenic/view.rb', line 54

def escaped_definition
  definition.gsub("\\", "\\\\\\")
end