Class: Mao::Query::JoinContext

Inherits:
Object
  • Object
show all
Defined in:
lib/mao/query.rb

Overview

A context for the #join DSL. Any non-lexically bound names hit JoinContext#method_missing, which constructs a Mao::Filter::Table for the table with that name.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object

Ensure args and block are both empty. Creates a Mao::Query for the name invoked, which ensures such a table exists. Assuming it exists, a Mao::Filter::Table for that query is constructed.



151
152
153
154
155
156
157
158
159
160
161
# File 'lib/mao/query.rb', line 151

def method_missing(name, *args, &block)
  if args.length > 0
    raise ArgumentError, "args not expected in #where subclause"
  end

  if block
    raise ArgumentError, "block not expected in #where subclause"
  end

  Mao::Filter::Table.new(Mao.query(name), true).freeze
end