Skip to content

Commit

Permalink
#1202 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jan 30, 2024
1 parent 587fa5c commit 36a277e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion objects/bouts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ def start(title)
end

def take(id)
raise "Bout ID '#{id}' must be integer" unless id.is_a?(Integer)
raise BoutNotFound, "The bout ##{id} doesn't exist" unless exists?(id)
require_relative 'bout'
Nb::Bout.new(@pgsql, @human, id)
end

def exists?(id)
raise Nb::Urror, "Bout ID '#{id}' must be integer" unless id.is_a?(Integer)
raise "Bout ID '#{id}' must be integer" unless id.is_a?(Integer)
!@pgsql.exec('SELECT id FROM bout WHERE id = $1', [id]).empty?
end
end
10 changes: 5 additions & 5 deletions objects/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def initialize(left, right)
end

def if_bout
yield false
# yield nothing
end

def to_s
Expand All @@ -141,7 +141,7 @@ def initialize(left, right)
end

def if_bout
yield false
# yield nothing
end

def to_s
Expand All @@ -161,7 +161,7 @@ def initialize(present, tag)
end

def if_bout
yield false
# yield nothing
end

def to_s
Expand All @@ -181,7 +181,7 @@ def initialize(left, right)
end

def if_bout
false
# yield nothing
end

def to_s
Expand All @@ -196,7 +196,7 @@ def to_sql
# Blank
class Blank
def if_bout
false
# yield nothing
end

def to_s
Expand Down
2 changes: 1 addition & 1 deletion test/test_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# License:: MIT
class Nb::QueryTest < Minitest::Test
def test_how_in_bout_works
query = Nb::Query.new('bout=3 and body=~hello')
query = Nb::Query.new('bout=3 and body=~hello and $foo+')
predicate = query.predicate
bout = nil
predicate.if_bout do |b|
Expand Down

0 comments on commit 36a277e

Please sign in to comment.