Skip to content

Instantly share code, notes, and snippets.

@brunto
Created July 27, 2020 19:55
Show Gist options
  • Save brunto/c09772ae64a8aa9e30259f52f58217b7 to your computer and use it in GitHub Desktop.
Save brunto/c09772ae64a8aa9e30259f52f58217b7 to your computer and use it in GitHub Desktop.
struct Daterange
def self.adapter
Lucky
end
module Lucky
alias ColumnType = UInt8
include Avram::Type
def parse(value : UInt8)
SuccessfulCast(UInt8).new(value)
end
def parse(values : Array(UInt8))
SuccessfulCast(Array(UInt8)).new values
end
def parse(value : String)
SuccessfulCast(UInt8).new(UInt8.new(value))
end
def parse(values : Array(String))
SuccessfulCast(Array(UInt8)).new values
end
def to_db(value : UInt8)
value.to_s
end
class Criteria(T, V) < Avram::Criteria(T, V)
end
end
end
@brunto
Copy link
Author

brunto commented Jul 27, 2020

Instead of SuccessfulCast(UInt8).new(UInt8.new(value))
I could also write the line like this SuccessfulCast(UInt8).new value.to_u8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment