mensa 0.6.6 → 0.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e66178b4b3d7f5431a1997a2abc5e2dcb048af8a5af7b5c7b865917ca9d0cb0f
4
- data.tar.gz: cd6fd8240ac179b2b2376e05790b152064b9c6c0ab355726dfd125238ea58007
3
+ metadata.gz: 5b3079b6b5933b04de4724402439729cb927b3babb82d0e1fac213b0387519b5
4
+ data.tar.gz: e047c77dee4e3cc8b4d201cedaa73a971964441a486571083d6d0c32e4bceee5
5
5
  SHA512:
6
- metadata.gz: b6fec9dc9274285bcaa1541b707960a57ec16a04b13344093916e9b980f09a803af34d3694fcb11a8158d9265f8a1d33f30584b49a50975c36c95beb6c7a3458
7
- data.tar.gz: b82a1ce70210d3b70ef9c79d1b3c3e23f492b666f79714aea7731d13c4e178b51f25c1fb8dc50dc7a82190d0b37e47530dfc875ff6434f53e0e3661ec2104664
6
+ metadata.gz: 97ae78d7d5927361dc6492ed97249008a5c8eadf1e75452772a4334affe4f3d9291b110b0fb3752b948f2c45ee48701dc5aa57b45a32b8fbf4c4d57a49900a56
7
+ data.tar.gz: 33d2c0be01a6b3f0bb4e0f8f8ee6c8e9a7aba97369915d938f1231b60af8ac944435e063f265943dac893eeaf3b1bf7063f628698912dee33838e19c408b36dd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mensa (0.6.5)
4
+ mensa (0.6.6)
5
5
  csv
6
6
  importmap-rails
7
7
  pagy (>= 43)
@@ -2,12 +2,14 @@ module Mensa::Config
2
2
  class FilterDsl
3
3
  include DslLogic
4
4
 
5
- option :operator, default: :is
6
- option :value
7
- option :collection
8
- option :scope
9
- option :multiple, default: false
5
+ option :operator, default: :is # Operator for filtering
6
+ option :value # Value for filtering
7
+
8
+ option :collection # Collection shown in filtering
9
+ option :scope # Scope for filtering
10
+ option :multiple, default: false # Multiple values allowed
10
11
  option :as
11
- option :operators
12
+ option :operators, default: [] # Supported operators
13
+ option :having, default: false # Needs having when filtering
12
14
  end
13
15
  end
@@ -12,6 +12,7 @@ module Mensa
12
12
  config_reader :value
13
13
  config_reader :scope
14
14
  config_reader :multiple
15
+ config_reader :having?
15
16
 
16
17
  class << self
17
18
  def OPERATORS
@@ -80,7 +81,7 @@ module Mensa
80
81
  record_scope.instance_exec(normalize(value), &scope)
81
82
  else
82
83
  query, hash = query_and_hash_for_operator
83
- record_scope = record_scope.where(query, hash) if query.present?
84
+ record_scope = (column.filter.having? ? record_scope.having(query, hash) : record_scope.where(query, hash)) if query.present?
84
85
  record_scope
85
86
  end
86
87
  end
@@ -99,14 +100,15 @@ module Mensa
99
100
  operators
100
101
  end
101
102
 
103
+ # Used in the where clause
102
104
  def query_and_hash_for_operator
103
- hash = { column: column.attribute_for_condition, value: normalize(value) }
105
+ hash = {column: column.attribute_for_condition, value: normalize(value)}
104
106
 
105
107
  query = case operator
106
108
  when :is_empty
107
- column.type == :string ? ":column IS NULL OR :column = ''" : ":column IS NULL"
109
+ (column.type == :string) ? ":column IS NULL OR :column = ''" : ":column IS NULL"
108
110
  when :isnt_empty
109
- column.type == :string ? ":column IS NOT NULL AND :column != ''" : ":column IS NOT NULL"
111
+ (column.type == :string) ? ":column IS NOT NULL AND :column != ''" : ":column IS NOT NULL"
110
112
  when :is_current
111
113
  ":column = :value"
112
114
  when :matches
data/lib/mensa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mensa
2
- VERSION = "0.6.6"
2
+ VERSION = "0.6.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mensa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-06-17 00:00:00.000000000 Z
11
+ date: 2026-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails