-
-
Save confact/27d62ee6ca27a47182bd1a665f9b6a3f to your computer and use it in GitHub Desktop.
Second attempt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AvramEnumConstants | |
module Lucky | |
alias ColumnType = Int32 | |
end | |
end | |
module AvramEnum | |
def self.adapter | |
Lucky | |
end | |
module Lucky | |
def from_db!(value : Int32) | |
new(value) | |
end | |
def parse(value : String) | |
from_value(value.to_i) | |
end | |
def parse(value : Int32) | |
from_value(value) | |
end | |
def to_db(value : Int32) | |
value.to_s | |
end | |
def to_db(value : Enum) | |
value.value.to_s | |
end | |
end | |
end | |
struct Enum | |
extend AvramEnum | |
include AvramEnumConstants | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MergeRequest < BaseModel | |
enum Status | |
Open = 0 | |
Closed = 1 | |
Merged = 2 | |
end | |
table do | |
column name : String | |
column status : MergeRequest::Status | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment