Sha256: f8f9969caa3c3ce7ec3a4a11cb98feba1d55e1f573fb77406ce0ec436f7faf5b
Contents?: true
Size: 733 Bytes
Versions: 4
Compression:
Stored size: 733 Bytes
Contents
# Add this to your ActiveRecord model with: # swifter_enum :<%= file_name %>, <%= class_name %>Enum class <%= class_name %>Enum < SwifterEnum::Base #set your values using a hash, or array of symbols #if you're using a hash with symbol:integer, then your database column should be of integer type # e.g. set_values ({active: 10, inactive: 20}) # or set_values active: 10, inactive: 20 #if you're using an array of symbols (or strings), then your database column should be of string type # e.g. set_values [:active,:passive] set_values ##Your Values Here## # you can now define methods on the enum # this would allow you to access YourModel.<%= file_name %>.squared #def squared # @value * @value #end end
Version data entries
4 entries across 4 versions & 1 rubygems