Skip to content

Commit 63d250b

Browse files
committed
Fix code formatting in concepts doc page
1 parent 9d3957d commit 63d250b

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

doc/kiba_extend_concepts.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,27 @@ However, even for one-off projects, it can be convenient to add settings for val
3131

3232
- 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:
3333

34-
```
34+
~~~
3535
setting :indemnity_fields,
3636
default: fields.select { |f| f.to_s.start_with?("ind") },
3737
reader: true
38-
```
38+
~~~
3939

4040
- If you need to dynamically set the default value of a setting, you must provide a custom constructor instead:
4141

42-
```
42+
~~~
4343
setting :indemnity_fields,
4444
default: %i[],
4545
reader: true,
4646
constructor: proc { fields.select { |f| f.to_s.start_with?("ind") } }
47-
```
47+
~~~
4848
A constructor is always a Proc or Lambda returning a value that can be frozen.
4949

5050
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.
5151

5252
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:
5353

54-
```
54+
~~~
5555
# Which TMS fields should be combined into a single :address_note value
5656
# per TMS ConAddress row. Conditional logic here automatically includes
5757
# fields in this setting based on other settings.
@@ -69,7 +69,7 @@ setting :note_fields,
6969
end
7070
value
7171
}
72-
```
72+
~~~
7373

7474
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.
7575

@@ -79,18 +79,18 @@ The `->(value)` is creating the constructor as a Lambda and passing in the setti
7979

8080
- 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:
8181

82-
```
82+
~~~
8383
Kiba::Tms::Exhibitions.delete_fields << :lightexpdaysperweek
8484
Kiba::Tms::Exhibitions.delete_fields << :lightexphoursperday
85-
```
85+
~~~
8686

8787
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.
8888

8989
If anything else had called `Kiba::Tms::Exhibitions.delete_fields` before this point, we'd get an error when we tried to do this.
9090

9191
- When the value of a setting is overwritten, it looks like you can set the value to something calculated without using a contructor:
9292

93-
```
93+
~~~
9494
Kiba::Tms::Exhibitions.config.post_shape_xforms = Kiba.job_segment do
9595
transform Merge::ConstantValueConditional,
9696
fieldmap: {exhibitionstatus: "Facility report received",
@@ -100,7 +100,7 @@ If anything else had called `Kiba::Tms::Exhibitions.delete_fields` before this p
100100
end
101101
transform Delete::Fields, fields: :text_entry
102102
end
103-
```
103+
~~~
104104

105105
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.
106106

0 commit comments

Comments
 (0)