diff options
author | Daniel Doubrovkine (dB.) @dblockdotorg <dblock@dblock.org> | 2020-09-24 14:47:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-24 14:47:48 -0400 |
commit | a30327a40b032767b5f61e7b22ec15ac1645cb76 (patch) | |
tree | d14c852181ddb262c475c171c69a863c70deee44 /README.md | |
parent | b24d6dca2c545637bc3cc3ac4d89f565fc27a9d0 (diff) | |
parent | 4cd2844357adfe9321e31c02b76c9945baaeffe4 (diff) | |
download | hashie-a30327a40b032767b5f61e7b22ec15ac1645cb76.tar.gz |
Merge pull request #530 from caalberts/dash-allowed-values
Hashie::Extensions::Dash::PredefinedValues
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 |