aboutsummaryrefslogtreecommitdiff
path: root/lib/some/messages.rb
diff options
context:
space:
mode:
authormms <git@sapka.me>2024-11-07 14:57:41 +0100
committermms <git@sapka.me>2024-11-07 14:57:41 +0100
commitacc8415d7109e8fb45bbfcd8cf545ebcf5b5d16a (patch)
tree1c8b1ec2efbd7602fa972aa7dbd6e8baa63ef515 /lib/some/messages.rb
init spike
Diffstat (limited to 'lib/some/messages.rb')
-rw-r--r--lib/some/messages.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/some/messages.rb b/lib/some/messages.rb
new file mode 100644
index 0000000..2f89d2b
--- /dev/null
+++ b/lib/some/messages.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+module Some
+ class Messages
+ AND_CONJUCTION = :and
+ OR_CONJUCTION = :or
+ DEFAULT_CONJUCTION = AND_CONJUCTION
+
+ attr_reader :query, :current_conjuction
+
+ def initialize
+ @query = []
+ @current_conjuction = AND_CONJUCTION
+ end
+
+ def or
+ @current_conjuction = OR_CONJUCTION
+ self
+ end
+
+ def filter(params)
+ query << params.map do |key, value|
+ unless value.is_a? Array
+ [current_conjuction, key, value.to_sym]
+ else
+
+ [current_conjuction,
+ value.map { |subarg| [OR_CONJUCTION, key, subarg] }]
+ end
+ end
+
+ self
+ end
+
+ def query_string
+
+ end
+ end
+end