diff options
author | mms <git@sapka.me> | 2024-11-10 00:20:05 +0100 |
---|---|---|
committer | mms <git@sapka.me> | 2024-11-10 00:20:05 +0100 |
commit | 68d7eb07d88338f28c40a5ba68061a7f4e35f340 (patch) | |
tree | 7c1e0ab62ff2a2d9cd89ae1bd113759bb3077f13 /lib/some/messages.rb | |
parent | 2b84ba48039818cf52f6acf3c06610212bf6f7c5 (diff) |
feat: dsl
Diffstat (limited to 'lib/some/messages.rb')
-rw-r--r-- | lib/some/messages.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/some/messages.rb b/lib/some/messages.rb index 5e2ff48..9f2520b 100644 --- a/lib/some/messages.rb +++ b/lib/some/messages.rb @@ -44,8 +44,10 @@ module Some end attr_accessor :query, :current_conjuction, :token_count + attr_reader :db - def initialize + def initialize(db:) + @db = db @query = [] @current_conjuction = AND_CONJUCTION @token_count = 0 @@ -72,6 +74,12 @@ module Some self end + def each + db.search_messages(query_string).each do |msg| + yield(Message.new(msg: msg)) + end + end + def add_filter_from_string(string) @query << Token.new(current_conjuction, :direct, string, self) end |