Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default option to vault_attribute #83

Merged
merged 1 commit into from
Jun 12, 2019
Merged

Conversation

justincampbell
Copy link
Contributor

This adds a :default option to vault_attribute, allowing a default value to be set if the underlying value is nil.

vault_attribute :metadata,
  serializer: :json,
  default: {}

vault_attribute :access_level,
  default: "readonly"

This enables a simple fix for applications affected by the breaking change introduced in #81 for serialize: :json empty values.

This adds a `:default` option to `vault_attribute`, allowing a default value to be set if the underlying value is `nil`.

```rb
vault_attribute :metadata,
  serializer: :json,
  default: {}

vault_attribute :access_level,
  default: "readonly"
```

This enables a simple fix for applications affected by the breaking change introduced in #81 for `serialize: :json` empty values.
Copy link

@findkim findkim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a neat option!

Would this mean if someone had used this library prior to #81 it would require setting the default to {} when updating the dependency or do a migration if it had relied on the nil or "" to decode as {}?

@justincampbell
Copy link
Contributor Author

@findkim yup! will call that out in the changelog

@justincampbell justincampbell merged commit b17ed1b into master Jun 12, 2019
@justincampbell justincampbell deleted the attribute-defaults branch June 12, 2019 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants