Releases: corp-gp/enum_machine
Releases · corp-gp/enum_machine
v2.1.0
perf: build class, better show_source (#43)
feat: add question predicate method for check in severals values (#44)
class TestClass
attr_accessor :state
def initialize(state)
@state = state
end
include EnumMachine[state: { enum: %w[choice in_delivery lost] }]
end
item = TestClass.new("choice")
item.state.choice__in_delivery? # => true
item.state.lost__in_delivery? # => false v2.0.0
Added
value_decoratoroption
# Value classes nested from base class
module ColorDecorator
def hex
case self
when Product::COLOR::RED then "#ff0000"
when Product::COLOR::GREEN then "#00ff00"
end
end
end
class Product
attr_accessor :color
include EnumMachine[color: { enum: %w[red green], value_decorator: ColorDecorator }]
end
product = Product.new
product.color = "red"
product.color.hex # => "#ff0000"Breaking changes
#decorator_modulemethod renamed to#enum_decorator