Skip to content

Commit

Permalink
Merge f47fb9c into ea33833
Browse files Browse the repository at this point in the history
  • Loading branch information
nrdobie committed Feb 27, 2015
2 parents ea33833 + f47fb9c commit 6a39d23
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/neo4j/active_node/query/query_proxy.rb
Expand Up @@ -112,16 +112,17 @@ def scoping
@model.current_scope = previous
end

METHODS = %w(where rel_where order skip limit)
METHODS = %w(where rel_where order rel_order skip limit)

METHODS.each do |method|
module_eval(%{
def #{method}(*args)
build_deeper_query_proxy(:#{method}, args)
end}, __FILE__, __LINE__)
end
# Since there is a rel_where method, it seems only natural for there to be node_where
# Since there is a rel_where and rel_order method, it seems only natural for there to be node_where and node_order
alias_method :node_where, :where
alias_method :node_order, :order
alias_method :offset, :skip
alias_method :order_by, :order

Expand Down Expand Up @@ -355,6 +356,13 @@ def links_for_rel_where_arg(arg)
end
end

# We don't accept strings here. If you want to use a string, just use order.
def links_for_rel_order_arg(arg)
arg.each_with_object([]) do |(key, value), result|
result << [:order, ->(_) { {rel_var => {key => value}} }]
end
end

def links_for_order_arg(arg)
[[:order, ->(v) { arg.is_a?(String) ? arg : {v => arg} }]]
end
Expand Down

0 comments on commit 6a39d23

Please sign in to comment.