Created
February 16, 2020 09:54
-
-
Save VasylShevchenko/2f8f7a739d1b0272f596f33c1b13c597 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 String | |
def to_boolean | |
ActiveRecord::Type::Boolean.new.cast(self) | |
end | |
end | |
class NilClass | |
def to_boolean | |
false | |
end | |
end | |
class TrueClass | |
def to_boolean | |
true | |
end | |
def to_i | |
1 | |
end | |
end | |
class FalseClass | |
def to_boolean | |
false | |
end | |
def to_i | |
0 | |
end | |
end | |
class Integer | |
def to_boolean | |
to_s.to_boolean | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment