Class: ActiveFacts::CQLLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/activefacts/cql.rb

Overview

This class has a load method for Polyglot to tell it how to require a CQL file. The CQL file is parsed to a vocabulary constellation, which is generated to Ruby code and eval’d, making the generated classes available. To make this Loader available, simply

require 'activefacts/cql'

Class Method Summary collapse

Class Method Details

.load(file) ⇒ Object

:nodoc:



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/activefacts/cql.rb', line 21

def self.load(file) #:nodoc:
  debug "Loading #{file}" do
    vocabulary = ActiveFacts::Input::CQL.readfile(file)

    ruby = StringIO.new
    @dumper = ActiveFacts::Generate::RUBY.new(vocabulary.constellation)
    @dumper.generate(ruby)
    ruby.rewind
    eval ruby.read, ::TOPLEVEL_BINDING
  end
end