active_fields 3.0.0 → 3.0.1

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: 6eaf6bd2afd182c6429e472d3f2b1a3dd70bd7a7baadd9a2bbc7dc421a39a7d7
4
- data.tar.gz: 6d77769c25f2c97bae25bee0ed66792fd719f4738610fa9b6f1c8d92f77f673a
3
+ metadata.gz: 86d3c04e24cae1b29e2f3a4957cec89fe64132c6b3d7f5432f16c6a84a0d8914
4
+ data.tar.gz: d1b6d2385b47913edf57ca4709e73eaf04f64f7d6d87a3c5e028b092f3b1a97e
5
5
  SHA512:
6
- metadata.gz: 78359ebaf1b2048564eed04a8de2464aa4650d3e16a03c9f701041daaae96c7c30924fd685d15aed7180dfccf340e86509db1a0bf08dcebd1fd72ee763b1d9a9
7
- data.tar.gz: 51680b929b2de155eb75e16efa328ff76e28dc0112f315ce350c378cc6fe4f77e7fee040c58a23626af7026b0afc008beac6e0a16be8892cdb89c192eaed0a5b
6
+ metadata.gz: abca69b126eacb5fc015d29fc0b7b67bc39e0905c68b8fb1a1fe86a80065838c80a5650fea5beac4bafdee1d123287aad405566115a58e2f0b39fa2c23fe33d5
7
+ data.tar.gz: f3e0e310b0a1a33f11c3226e2e678fe84bd6787609c189afe6e086b7e039b0852b13df0fcdf08759e06dc1ccf931ba8b9eeff00137faae843a26b02267f77954
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [3.0.1] - 2025-11-28
4
+ - Fixed an issue where searching with `v: false` was treated as `nil` due to `false || nil` logic
5
+
3
6
  ## [3.0.0] - 2025-11-27
4
7
  - Disabled fields name format validation
5
8
  - Added scope functionality: _Active Field_ can now be limited to a specific context, allowing different sets of fields per group within the same _Customizable_ model.
data/README.md CHANGED
@@ -5,7 +5,38 @@
5
5
  [![Github Actions CI](https://github.com/lassoid/active_fields/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/lassoid/active_fields/actions/workflows/main.yml)
6
6
 
7
7
  **ActiveFields** is a _Rails_ plugin that implements the _Entity-Attribute-Value_ (_EAV_) pattern,
8
- enabling the addition of custom fields to any model at runtime without requiring changes to the database schema.
8
+ enabling the addition of custom fields to any model at runtime without requiring changes to the database schema or application code.
9
+
10
+ It may look similar to other gems like [attr_json](https://github.com/jrochkind/attr_json) or [store_attribute](https://github.com/palkan/store_attribute), but it solves a fundamentally different problem. While those tools allow you to add fields without migrations, they still require developer work - you must write code to define each field.
11
+
12
+ The main use case of _EAV_ in general, and _ActiveFields_ in particular, is to enable **any application user** (not just developers) to add their own fields. Not just without migrations, but without touching the source code at all. These are truly data-driven fields that can be created, modified, and managed entirely through your application's interface.
13
+
14
+ ## Table of Contents
15
+
16
+ - [Key Concepts](#key-concepts)
17
+ - [Models Structure](#models-structure)
18
+ - [Requirements](#requirements)
19
+ - [Installation](#installation)
20
+ - [Field Types](#field-types)
21
+ - [Fields Base Attributes](#fields-base-attributes)
22
+ - [Field Types Summary](#field-types-summary)
23
+ - [Search Functionality](#search-functionality)
24
+ - [Configuration](#configuration)
25
+ - [Limiting Field Types for a Customizable](#limiting-field-types-for-a-customizable)
26
+ - [Customizing Internal Model Classes](#customizing-internal-model-classes)
27
+ - [Adding Custom Field Types](#adding-custom-field-types)
28
+ - [Multi-tenancy (scoping)](#multi-tenancy-scoping)
29
+ - [Localization (I18n)](#localization-i18n)
30
+ - [Current Restrictions](#current-restrictions)
31
+ - [API Overview](#api-overview)
32
+ - [Fields API](#fields-api)
33
+ - [Values API](#values-api)
34
+ - [Customizable API](#customizable-api)
35
+ - [Global Config](#global-config)
36
+ - [Registry](#registry)
37
+ - [Development](#development)
38
+ - [Contributing](#contributing)
39
+ - [License](#license)
9
40
 
10
41
  ## Key Concepts
11
42
 
@@ -292,6 +323,9 @@ classDiagram
292
323
  All _Active Field_ model names start with `ActiveFields::Field`.
293
324
  We replace it with `**` for conciseness.
294
325
 
326
+ <details>
327
+ <summary><strong>Table</strong></summary>
328
+
295
329
  | Active Field model | Type name | Attributes | Options |
296
330
  |---------------------------------|------------------|------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
297
331
  | `**::Boolean` | `boolean` | `default_value`<br>(`boolean` or `nil`) | `required`(`boolean`) - the value must not be `false`<br>`nullable`(`boolean`) - the value could be `nil` |
@@ -309,6 +343,8 @@ We replace it with `**` for conciseness.
309
343
  | `**::TextArray` | `text_array` | `default_value`<br>(`array[string]`) | `min_length`(`integer`) - minimum value length allowed, for each element<br>`max_length`(`integer`) - maximum value length allowed, for each element<br>`min_size`(`integer`) - minimum value size<br>`max_size`(`integer`) - maximum value size |
310
344
  | _Your custom class can be here_ | _..._ | _..._ | _..._ |
311
345
 
346
+ </details>
347
+
312
348
  **Note:** Options marked with **\*** are mandatory.
313
349
 
314
350
  ### Search Functionality
@@ -354,14 +390,18 @@ Key details:
354
390
 
355
391
  Supported _operations_ and _operators_ for each _Active Field_ type are listed below.
356
392
 
357
- #### Boolean
393
+ <details>
394
+ <summary><strong>Boolean</strong></summary>
358
395
 
359
396
  | Operation | Operator | Description |
360
397
  |------------|----------|-----------------------------|
361
398
  | `eq` | `=` | Value is equal to given |
362
399
  | `not_eq` | `!=` | Value is not equal to given |
363
400
 
364
- #### Date
401
+ </details>
402
+
403
+ <details>
404
+ <summary><strong>Date</strong></summary>
365
405
 
366
406
  | Operation | Operator | Description |
367
407
  |------------|----------|-----------------------------------------|
@@ -372,7 +412,10 @@ Supported _operations_ and _operators_ for each _Active Field_ type are listed b
372
412
  | `lt` | `<` | Value is less than given |
373
413
  | `lteq` | `<=` | Value is less than or equal to given |
374
414
 
375
- #### DateArray
415
+ </details>
416
+
417
+ <details>
418
+ <summary><strong>DateArray</strong></summary>
376
419
 
377
420
  | Operation | Operator | Description |
378
421
  |---------------|----------|----------------------------------------------------------------|
@@ -393,7 +436,10 @@ Supported _operations_ and _operators_ for each _Active Field_ type are listed b
393
436
  | `size_lt` | `#<` | Array value size is less than given |
394
437
  | `size_lteq` | `#<=` | Array value size is less than or equal to given |
395
438
 
396
- #### DateTime
439
+ </details>
440
+
441
+ <details>
442
+ <summary><strong>DateTime</strong></summary>
397
443
 
398
444
  | Operation | Operator | Description |
399
445
  |------------|----------|-----------------------------------------|
@@ -404,7 +450,10 @@ Supported _operations_ and _operators_ for each _Active Field_ type are listed b
404
450
  | `lt` | `<` | Value is less than given |
405
451
  | `lteq` | `<=` | Value is greater than or equal to given |
406
452
 
407
- #### DateTimeArray
453
+ </details>
454
+
455
+ <details>
456
+ <summary><strong>DateTimeArray</strong></summary>
408
457
 
409
458
  | Operation | Operator | Description |
410
459
  |---------------|----------|----------------------------------------------------------------|
@@ -425,7 +474,10 @@ Supported _operations_ and _operators_ for each _Active Field_ type are listed b
425
474
  | `size_lt` | `#<` | Array value size is less than given |
426
475
  | `size_lteq` | `#<=` | Array value size is less than or equal to given |
427
476
 
428
- #### Decimal
477
+ </details>
478
+
479
+ <details>
480
+ <summary><strong>Decimal</strong></summary>
429
481
 
430
482
  | Operation | Operator | Description |
431
483
  |------------|----------|-----------------------------------------|
@@ -436,7 +488,10 @@ Supported _operations_ and _operators_ for each _Active Field_ type are listed b
436
488
  | `lt` | `<` | Value is less than given |
437
489
  | `lteq` | `<=` | Value is greater than or equal to given |
438
490
 
439
- #### DecimalArray
491
+ </details>
492
+
493
+ <details>
494
+ <summary><strong>DecimalArray</strong></summary>
440
495
 
441
496
  | Operation | Operator | Description |
442
497
  |---------------|----------|----------------------------------------------------------------|
@@ -457,14 +512,20 @@ Supported _operations_ and _operators_ for each _Active Field_ type are listed b
457
512
  | `size_lt` | `#<` | Array value size is less than given |
458
513
  | `size_lteq` | `#<=` | Array value size is less than or equal to given |
459
514
 
460
- #### Enum
515
+ </details>
516
+
517
+ <details>
518
+ <summary><strong>Enum</strong></summary>
461
519
 
462
520
  | Operation | Operator | Description |
463
521
  |------------|----------|-----------------------------|
464
522
  | `eq` | `=` | Value is equal to given |
465
523
  | `not_eq` | `!=` | Value is not equal to given |
466
524
 
467
- #### EnumArray
525
+ </details>
526
+
527
+ <details>
528
+ <summary><strong>EnumArray</strong></summary>
468
529
 
469
530
  | Operation | Operator | Description |
470
531
  |---------------|----------|----------------------------------------------------|
@@ -477,7 +538,10 @@ Supported _operations_ and _operators_ for each _Active Field_ type are listed b
477
538
  | `size_lt` | `#<` | Array value size is less than given |
478
539
  | `size_lteq` | `#<=` | Array value size is less than or equal to given |
479
540
 
480
- #### Integer
541
+ </details>
542
+
543
+ <details>
544
+ <summary><strong>Integer</strong></summary>
481
545
 
482
546
  | Operation | Operator | Description |
483
547
  |------------|----------|-----------------------------------------|
@@ -488,7 +552,10 @@ Supported _operations_ and _operators_ for each _Active Field_ type are listed b
488
552
  | `lt` | `<` | Value is less than given |
489
553
  | `lteq` | `<=` | Value is greater than or equal to given |
490
554
 
491
- #### IntegerArray
555
+ </details>
556
+
557
+ <details>
558
+ <summary><strong>IntegerArray</strong></summary>
492
559
 
493
560
  | Operation | Operator | Description |
494
561
  |---------------|----------|----------------------------------------------------------------|
@@ -509,7 +576,10 @@ Supported _operations_ and _operators_ for each _Active Field_ type are listed b
509
576
  | `size_lt` | `#<` | Array value size is less than given |
510
577
  | `size_lteq` | `#<=` | Array value size is less than or equal to given |
511
578
 
512
- #### Text
579
+ </details>
580
+
581
+ <details>
582
+ <summary><strong>Text</strong></summary>
513
583
 
514
584
  | Operation | Operator | Description |
515
585
  |-------------------|----------|-------------------------------------------------------------|
@@ -528,7 +598,10 @@ Supported _operations_ and _operators_ for each _Active Field_ type are listed b
528
598
  | `not_iend_with` | `!$*` | Value doesn't end with given substring (case-insensitive) |
529
599
  | `not_icontain` | `!~*` | Value doesn't contain given substring (case-insensitive) |
530
600
 
531
- #### TextArray
601
+ </details>
602
+
603
+ <details>
604
+ <summary><strong>TextArray</strong></summary>
532
605
 
533
606
  | Operation | Operator | Description |
534
607
  |------------------|----------|-------------------------------------------------------------|
@@ -543,6 +616,8 @@ Supported _operations_ and _operators_ for each _Active Field_ type are listed b
543
616
  | `size_lt` | `#<` | Array value size is less than given |
544
617
  | `size_lteq` | `#<=` | Array value size is less than or equal to given |
545
618
 
619
+ </details>
620
+
546
621
  ## Configuration
547
622
 
548
623
  ### Limiting Field Types for a Customizable
@@ -855,7 +930,7 @@ IpFinder.new(active_field: ip_active_field).search(op: "eq", value: "127.0.0.1")
855
930
  IpArrayFinder.new(active_field: ip_array_active_field).search(op: "#>=", value: 5)
856
931
  ```
857
932
 
858
- ### Scoping
933
+ ### Multi-tenancy (scoping)
859
934
 
860
935
  The scoping feature enables multi-tenancy or context-based field definitions per model.
861
936
  It allows you to define different sets of _Active Fields_ for different scopes (e.g., different tenants, organizations, or contexts).
@@ -71,13 +71,17 @@ module ActiveFields
71
71
  filter = filter.to_h if filter.respond_to?(:permitted?)
72
72
  filter = filter.with_indifferent_access
73
73
 
74
- active_field = active_fields_by_name[filter[:n] || filter[:name]]
74
+ name = filter.key?(:n) ? filter[:n] : filter[:name]
75
+ operator = filter.key?(:op) ? filter[:op] : filter[:operator]
76
+ value = filter.key?(:v) ? filter[:v] : filter[:value]
77
+
78
+ active_field = active_fields_by_name[name]
75
79
  next query if active_field.nil?
76
80
  next query if active_field.value_finder.nil?
77
81
 
78
82
  active_values = active_field.value_finder.search(
79
- op: filter[:op] || filter[:operator],
80
- value: filter[:v] || filter[:value],
83
+ op: operator,
84
+ value: value,
81
85
  )
82
86
  next query if active_values.nil?
83
87
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveFields
4
- VERSION = "3.0.0"
4
+ VERSION = "3.0.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_fields
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Usanov