-
-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added expressions to where condition #46
Conversation
Sequel already has an option to define you condition in a code block, like this: ```ruby UserRepository.where{ age > 31 } ```
# # => SELECT * FROM `articles` WHERE (`publish_at` > DATE('2014-07-29')) | ||
def where(condition=nil, &blk) | ||
condition or blk or raise ArgumentError.new("You need to specify an condition.") | ||
condition = blk unless condition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we avoid this line and do:
def where(condition=nil, &blk)
condition = condition or blk or raise ArgumentError.new('You need to specify an condition.')
conditions.push([:where, condition])
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea. with returning self
@coenert Thanks for this PR, it looks good. |
@jodosha thanks! i also implemented the feature for |
@coenert that looks great! Can you please add some extra examples to all the three methods? Thanks. |
@coenert Looks good, merging! 👍 |
added expressions to where condition
Closes #42