Class: Upkeep::SQLGlot::Source

Inherits:
Data
  • Object
show all
Defined in:
lib/upkeep/sqlglot.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind



77
78
79
# File 'lib/upkeep/sqlglot.rb', line 77

def kind
  @kind
end

#scopeObject (readonly)

Returns the value of attribute scope



77
78
79
# File 'lib/upkeep/sqlglot.rb', line 77

def scope
  @scope
end

#tableObject (readonly)

Returns the value of attribute table



77
78
79
# File 'lib/upkeep/sqlglot.rb', line 77

def table
  @table
end

Class Method Details

.from_native(value) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/upkeep/sqlglot.rb', line 78

def self.from_native(value)
  case value.fetch("kind")
  when "table"
    new(
      kind: :table,
      table: TableRef.from_native(value.fetch("table")),
      scope: nil
    )
  when "scope"
    new(
      kind: :scope,
      table: nil,
      scope: Scope.from_native(value.fetch("scope"))
    )
  else
    raise KeyError, "Unknown SQLGlot source kind: #{value["kind"].inspect}"
  end
end