Skip to content

Commit

Permalink
fixed bug in a View.define("name") API
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Andreev committed Apr 28, 2008
1 parent 792ca93 commit 63edfa7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions lib/strokedb/views/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,17 @@ def [](name)
# View.define(:name => "view_name", :option => "value") do |viewdoc| ... end
#
def define(*args, &block)
options = args.pop.stringify_keys rescue { }
if args.first.is_a? String
options = args[1] || {}
options['name'] = args.first
else
options = args[0] || {}
end

options = options.stringify_keys

# TODO: find the view through the Views' view.
name = options['name'] || args.pop
name = options['name']
unless name
raise ArgumentError, "View name must be specified!"
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/strokedb/views/view_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

before(:all) do
setup_default_store
@view = View.define(:name => "post_comments") do |view|
@view = View.define("post_comments") do |view|
def view.map(uuid, doc)
doc['type'] =~ /comment/ ? [[[doc.parent, doc.created_at], doc]] : nil
end
Expand Down

0 comments on commit 63edfa7

Please sign in to comment.