diff options
author | Albert Salim <albertlimca@gmail.com> | 2020-09-19 13:02:13 +0800 |
---|---|---|
committer | Albert Salim <albertlimca@gmail.com> | 2020-09-20 11:26:57 +0800 |
commit | 4cd2844357adfe9321e31c02b76c9945baaeffe4 (patch) | |
tree | d14c852181ddb262c475c171c69a863c70deee44 /README.md | |
parent | b24d6dca2c545637bc3cc3ac4d89f565fc27a9d0 (diff) | |
download | hashie-4cd2844357adfe9321e31c02b76c9945baaeffe4.tar.gz |
Add Hashie::Extensions::Dash::AllowList
Extends a Dash with the ability to
accept only predefined values on a property.
#61
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -43,6 +43,7 @@ - [PropertyTranslation](#propertytranslation) - [Mash and Rails 4 Strong Parameters](#mash-and-rails-4-strong-parameters) - [Coercion](#coercion-1) + - [PredefinedValues](#predefinedvalues) - [Trash](#trash) - [Clash](#clash) - [Rash](#rash) @@ -968,6 +969,20 @@ class UserHash < Hashie::Dash end ``` +### PredefinedValues + +The `Hashie::Extensions::Dash::PredefinedValues` mixin extends a Dash with +the ability to accept predefined values on a property. + +```ruby +class UserHash < Hashie::Dash + include Hashie::Extensions::PredefinedValues + + property :gender, values: %i[male female prefer_not_to_say] + property :age, values: (0..150) +end +``` + ## Trash A Trash is a Dash that allows you to translate keys on initialization. It mixes |