aboutsummaryrefslogtreecommitdiff
path: root/lib/some/messages.rb
diff options
context:
space:
mode:
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