Class: Squeel::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/squeel/dsl.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_id, *args) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/squeel/dsl.rb', line 20

def method_missing(method_id, *args)
  if args.empty?
    Nodes::Stub.new method_id
  elsif (args.size == 1) && (Class === args[0])
    Nodes::Join.new(method_id, Arel::InnerJoin, args[0])
  else
    Nodes::Function.new method_id, args
  end
end

Class Method Details

.eval(&block) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/squeel/dsl.rb', line 12

def self.eval(&block)
  if block.arity > 0
    yield self.new
  else
    self.new.instance_eval(&block)
  end
end