Permalink
Browse files

Makes use of try do ... end for lexical scoping

  • Loading branch information...
1 parent fcb2344 commit aae2fbb08318e0cf3ac85ab31358de7f89b72ce9 Yurii Rashkovskii committed Jul 9, 2012
Showing with 12 additions and 9 deletions.
  1. +10 −6 lib/exql.ex
  2. +2 −3 lib/queries/select.ex
View
@@ -24,15 +24,19 @@ defmodule ExQL do
[] -> quote do: unquote(query)
[expr] ->
quote do
- import ExQL.Select
- require ExQL.Utils
- ExQL.Utils.back_pipeline(unquote(query), unquote(expr))
+ try do
+ import ExQL.Select
+ require ExQL.Utils
+ ExQL.Utils.back_pipeline(unquote(query), unquote(expr))
+ end
end
[l,r] ->
quote do
- import ExQL.Select
- require ExQL.Utils
- ExQL.Utils.back_pipeline(unquote(query), ExQL.Utils.back_pipeline(unquote(l), unquote(r)))
+ try do
+ import ExQL.Select
+ require ExQL.Utils
+ ExQL.Utils.back_pipeline(unquote(query), ExQL.Utils.back_pipeline(unquote(l), unquote(r)))
+ end
end
end
end
@@ -6,12 +6,11 @@ defrecord ExQL.Select, dict: [fields: :*] do
defmacro where(block, query) when is_tuple(block) do
quote do
- f = fn() ->
+ try do
import Elixir.Builtin, except: unquote(ExQL.Condition.__ops__)
import ExQL.Condition, only: unquote(ExQL.Condition.__ops__)
- unquote(block)
+ ExQL.Select._where(unquote(block), unquote(query))
end
- ExQL.Select._where(f.(), unquote(query))
end
end
defmacro where(value, query) do

0 comments on commit aae2fbb

Please sign in to comment.