# Thread-unsichere Lazy Initialization in PostActionType

**URL:** <https://meta.discourse.org/t/thread-unsafe-lazy-initialization-in-postactiontype/225447>\
**Category:** Bug\
**Created:** [27. April 2022 um 15:28 UTC](https://meta.discourse.org/t/thread-unsafe-lazy-initialization-in-postactiontype/225447 "2022-04-27T15:28:22Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![eregon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eregon/32/188324_2.png) [@eregon](https://meta.discourse.org/u/eregon)\
**Post date:** [2. Mai 2022 um 10:13 UTC](https://meta.discourse.org/t/thread-unsafe-lazy-initialization-in-postactiontype/225447/5 "2022-05-02T10:13:45Z")

</div>

Es könnte auch so gemacht werden, was insbesondere vermeiden würde, die ivar zweimal zu lesen und deutlicher machen würde, dass sie eager-initialisiert ist (die Logik könnte zur Organisation natürlich auch in einer `initial_flag_settings`-Hilfsmethode stehen):

```ruby
  class << self
    attr_reader :flag_settings
  end

  @flag_settings = FlagSettings.new
  @flag_settings.add(
    3,
    :off_topic,
    notify_type: true,
    auto_action_type: true,
  )
  # ...

```

---

_[View the full topic](https://meta.discourse.org/t/thread-unsafe-lazy-initialization-in-postactiontype/225447)._
