diff options
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 |