Module: Eql

Defined in:
lib/eql.rb,
lib/eql/proxy.rb,
lib/eql/config.rb,
lib/eql/builder.rb,
lib/eql/version.rb,
lib/eql/adapters/base.rb,
lib/eql/adapter_factory.rb,
lib/eql/template_loader.rb,
lib/eql/adapters/active_record.rb

Overview

Eql module renders ERB query templates and runs them

Defined Under Namespace

Modules: Adapters Classes: AdapterFactory, Builder, Config, Proxy, TemplateLoader

Constant Summary collapse

VERSION =

Returns gem version

Returns:

  • (String)

    returns gem version

'0.1.0'

Class Method Summary collapse

Class Method Details

.configEql::Config

Returns:



57
58
59
# File 'lib/eql.rb', line 57

def config
  @config ||= Config.new
end

.configure {|config| ... } ⇒ Object

Setup

Yields:



64
65
66
# File 'lib/eql.rb', line 64

def configure
  yield(config)
end

.execute(tmpl, params = nil) ⇒ Object

Execute a builder with template and params

Parameters:

  • tmpl (String, Symbol)

    template’s name

  • params (Object, nil) (defaults to: nil)

    template’s params

Returns:

  • (Object)

    returns excution results



39
40
41
# File 'lib/eql.rb', line 39

def execute(tmpl, params = nil)
  load(tmpl, params).execute
end

.load(tmpl, params = nil) ⇒ Eql::Builder

Load a builder with template and params

Parameters:

  • tmpl (String, Symbol)

    template’s name

  • params (Object, nil) (defaults to: nil)

    template’s params

Returns:



27
28
29
# File 'lib/eql.rb', line 27

def load(tmpl, params = nil)
  new.tap { |b| b.load(tmpl, params) }
end

.new(path = nil, conn = nil) ⇒ Object

Create new builder

Parameters:

  • path (Array<String>, String, nil) (defaults to: nil)

    template’s root folder

  • conn (Object, nil) (defaults to: nil)

    DB connection or cursor



15
16
17
# File 'lib/eql.rb', line 15

def new(path = nil, conn = nil)
  Builder.new(path || config.path, conn)
end

.register_adapter(key, klass) ⇒ Object

See Also:

  • Eql::AdapterFactory#redister_adapter


71
72
73
# File 'lib/eql.rb', line 71

def register_adapter(key, klass)
  AdapterFactory.register_adapter(key, klass)
end

.template(erb) ⇒ Eql::Builder

Load a builder with template content

Parameters:

  • erb (String)

    template’s content

Returns:



50
51
52
# File 'lib/eql.rb', line 50

def template(erb)
  new.tap { |b| b.template(erb) }
end