Skip to content

Allow defining enum value mapping #2

Description

@julik

At the moment state_machine_enum relies on Postgres enums. The values for the enum attribute are collected from the collector, but there is no way to map them either to specific integers (closed: 0, open: 1) or to strings (closed: "CLOSED", open: "OPEN") as they are picked up from the Collector. At the moment the only mapping we support is from string to itself - closed: "closed", open: "open"} We need a way to make this customisable - one way could be like this:

state_machine_enum :foo do |sm|
    sm.value_map { |enum| enum_sym.to_s.upcase }
end

or similar. Or we need to add a test that the passed mapping overrides the one received from the Collector and there is a check if there is a discrepancy (come to think of it - this might even be better, as the standard Rails way of defining an enum can then be preserved)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions