Skip to content

Commit

Permalink
add regex like support
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanstout committed Nov 16, 2015
1 parent e040137 commit af66d45
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/volt/tasks/store_tasks.rb
Expand Up @@ -47,7 +47,7 @@ def save(collection, path, data)
next nil
end.fail do |err|
# An error object, convert to hash
Promise.new.reject(err.to_h)
Promise.new.reject(err.try(:to_h) || err.to_s)
end

Thread.current['in_channel'] = nil
Expand Down
15 changes: 12 additions & 3 deletions lib/volt/models/persistors/query/query_identifier.rb
Expand Up @@ -17,14 +17,23 @@ def method_missing(method_name, *args)
method_name = method_name.to_s
# c for call

args = escape(args)

QueryIdentifier.new(['c', @from, method_name, *args])
end

def escape(args)
args.map do |arg|
if arg.is_a?(Array)
# Escape the array
arg.unshift('a')
elsif arg.is_a?(Regexp)
# Track regexp
['r', arg.to_s]
else
arg
end
end

QueryIdentifier.new(['c', @from, method_name, *args])
end

def ==(val)
Expand Down Expand Up @@ -54,7 +63,7 @@ def +(val)
end

def __op(*args)
QueryOp.new(['c', self, *args])
QueryOp.new(['c', self, *escape(args)])
end

def coerce(other)
Expand Down
6 changes: 4 additions & 2 deletions lib/volt/page/bindings/view_binding.rb
Expand Up @@ -157,8 +157,10 @@ def remove_current_controller_and_template
if @grouped_controller && @current_controller_handler
# We remove the controller after all of the current rendering is done.
Timers.next_tick do
# Remove a reference for the controller in the group.
@grouped_controller.remove(@current_controller_handler.controller.class)
if @current_controller_handler
# Remove a reference for the controller in the group.
@grouped_controller.remove(@current_controller_handler.controller.class)
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/volt/version.rb
@@ -1,5 +1,5 @@
module Volt
module Version
STRING = '0.9.7.pre5'
STRING = '0.9.7.pre6'
end
end

0 comments on commit af66d45

Please sign in to comment.