From 68d7eb07d88338f28c40a5ba68061a7f4e35f340 Mon Sep 17 00:00:00 2001 From: mms Date: Sun, 10 Nov 2024 00:20:05 +0100 Subject: feat: dsl --- lib/some/messages.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/some/messages.rb') 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 -- cgit v1.2.3