Module: WorkingSet

Defined in:
lib/working_set.rb,
lib/working_set/sql_compiler.rb,
lib/working_set/ability_array.rb,
lib/working_set/query_language.rb,
lib/working_set/active_record_compiler.rb

Defined Under Namespace

Modules: QueryLanguage Classes: AbilityArray, ActiveRecordCompiler, InvalidExpression, Parser, QueryLanguageParser, SQLCompiler, SyntaxError

Class Method Summary collapse

Class Method Details

.check_record(expression, record) ⇒ Object


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

def check_record(expression, record)
  tree = parse(expression)
  ::WorkingSet::ActiveRecordCompiler.new(tree).compile(record)
end

.parse(expression, options = {}) ⇒ Object


37
38
39
40
41
42
43
# File 'lib/working_set.rb', line 37

def parse(expression, options = {})
  @parser ||= ::WorkingSet::Parser.new
  unless tree = @parser.parse(expression.to_s, options)
    raise SyntaxError, @parser.failure_reason + "\nExpression: " + expression.inspect
  end
  tree
end

.to_sql(expression, options = {}) ⇒ Object


45
46
47
48
# File 'lib/working_set.rb', line 45

def to_sql(expression, options = {})
  tree = parse(expression)
  ::WorkingSet::SQLCompiler.new(tree).compile(options)
end