You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/kiba_extend_concepts.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,27 +31,27 @@ However, even for one-off projects, it can be convenient to add settings for val
31
31
32
32
- Values assigned to a setting (including) `default` value must respond to `#freeze` method. You generally cannot calculate the `default` value of a setting. For example, this will raise an error:
A constructor is always a Proc or Lambda returning a value that can be frozen.
49
49
50
50
The first time `YourApp.indemnity_fields` is called from elsewhere in your code, the constructor code is called and the value is set to its result and frozen.
51
51
52
52
Here is a more complex example defining the `:note_fields` setting for constituent addresses in kiba-tms. It is slightly modified from reality to make a better example:
53
53
54
-
```
54
+
~~~
55
55
# Which TMS fields should be combined into a single :address_note value
56
56
# per TMS ConAddress row. Conditional logic here automatically includes
57
57
# fields in this setting based on other settings.
@@ -69,7 +69,7 @@ setting :note_fields,
69
69
end
70
70
value
71
71
}
72
-
```
72
+
~~~
73
73
74
74
The `->(value)` is creating the constructor as a Lambda and passing in the setting's `default` value as `value`. The `:addressnote` field is always treated as a note field from this table. Other fields get added to this list based on the specified criteria.
75
75
@@ -79,18 +79,18 @@ The `->(value)` is creating the constructor as a Lambda and passing in the setti
79
79
80
80
- Setting values are not actually frozen until they are called. This is what allows us to do the following in a kiba-tms individual client project's main config:
The kiba-tms and client project main configs are read in/defined before any thing else happens, so we can add some fields to be removed when we process the Exhibitions table.
88
88
89
89
If anything else had called `Kiba::Tms::Exhibitions.delete_fields` before this point, we'd get an error when we tried to do this.
90
90
91
91
- When the value of a setting is overwritten, it looks like you can set the value to something calculated without using a contructor:
92
92
93
-
```
93
+
~~~
94
94
Kiba::Tms::Exhibitions.config.post_shape_xforms = Kiba.job_segment do
@@ -100,7 +100,7 @@ If anything else had called `Kiba::Tms::Exhibitions.delete_fields` before this p
100
100
end
101
101
transform Delete::Fields, fields: :text_entry
102
102
end
103
-
```
103
+
~~~
104
104
105
105
Whatever's after the `=` is evaluated first and the result of that evaluation is set as the settingvalue. The result of the `Kiba.job_segment` block is a `String`, so it can be a setting value.
0 commit comments