File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -59,15 +59,15 @@ gem "enum_machine"
5959``` ruby
6060# With ActiveRecord
6161class Product < ActiveRecord ::Base
62- enum_machine :color , %w[red green]
62+ enum_machine :color , %w[red green yellow ]
6363end
6464
6565# Or with plain class
6666class Product
6767 # attributes must be defined before including the EnumMachine module
6868 attr_accessor :color
6969
70- include EnumMachine [color: { enum: %w[red green] }]
70+ include EnumMachine [color: { enum: %w[red green yellow ] }]
7171 # or reuse from model
7272 Product ::COLOR .enum_decorator
7373end
@@ -85,6 +85,8 @@ product = Product.new
8585product.color # => nil
8686product.color = " red"
8787product.color.red? # => true
88+ product.color.red__yellow? # => true # when color is green or yellow
89+ product.color.green__yellow? # => false
8890product.color.human_name # => "Красный"
8991```
9092
You can’t perform that action at this time.
0 commit comments