-
-
Save indigoviolet/cfdd6bf0d23ec2a9b499bed7d1bab37f to your computer and use it in GitHub Desktop.
fin blog embed
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 ActiveRecordEnumValue < Contracts::CallableClass | |
def initialize(enum) | |
@enum_contract = Contracts::Enum[*enum.values] | |
end | |
def valid?(val) | |
Contract.valid?(val, @enum_contract) | |
end | |
end | |
class ActiveRecordEnumKey < Contracts::CallableClass | |
def initialize(enum) | |
@enum_contract = Contracts::Enum[*enum.keys] | |
end | |
def valid?(val) | |
Contract.valid?(val, @enum_contract) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment