discourse/plugins/chat/spec/lib
Loïc Guitaut 885ab9a015
DEV: Introduce an `array` type for Chat contracts (#22278)
This small patch registers a new `ActiveModel` type: `array`.
It will split a string on `,` to create a new array. If the value is
already an array, nothing will happen and for all other types, it will
wrap the value in an array.

Here’s an example on an existing contract:
```ruby
  attribute :target_usernames

  before_validation do
    self.target_usernames =
      (
        if target_usernames.is_a?(String)
          target_usernames.split(",")
        else
          target_usernames
        end
      )
  end

  # can be rewritten as:

  attribute :target_usernames, :array
```
2023-06-27 10:51:58 +10:00
..
chat DEV: Introduce an `array` type for Chat contracts (#22278) 2023-06-27 10:51:58 +10:00
service_runner_spec.rb DEV: Add policy objects to services 2023-05-25 12:34:00 +02:00