Class: TableQuery::SchemaLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/table-query/schema-loader.rb

Overview

SchemaLoader provides functions to load schema file and evaluation context.

Defined Under Namespace

Classes: Context, VariableQuery, VariableTable, VariableType

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src, filename) ⇒ SchemaLoader

Create a new loader.

Parameters:

  • src (String)

    schema source

  • filename (String)

    filename



77
78
79
80
81
# File 'lib/table-query/schema-loader.rb', line 77

def initialize(src, filename)
  @src = src
  @filename = filename
  @context = Context.new
end

Class Method Details

.load(src, filename) ⇒ Object

Load schema file and evaluate.

Parameters:

  • src (String)

    schema source

  • filename (String)

    filename



67
68
69
# File 'lib/table-query/schema-loader.rb', line 67

def self.load(src, filename)
  new(src, filename).eval
end

Instance Method Details

#evalArray<Array<Type>, TableSchema, Array<QuerySchema>>

Evaluate schema file.

Returns:



87
88
89
90
# File 'lib/table-query/schema-loader.rb', line 87

def eval
  @context.binding.eval(@src, @filename)
  [@context.type.value, @context.table.value, @context.query.value]
end