Skip to content

Instantly share code, notes, and snippets.

@tpitale
Created January 27, 2014 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tpitale/8652178 to your computer and use it in GitHub Desktop.
Save tpitale/8652178 to your computer and use it in GitHub Desktop.
The things we do for legacy databases
require 'dm-core'
class BooleanChar < DataMapper::Property::String
def primitive?(value)
super || value == true || value == false
end
# prepare for model use
def load(value)
case value
when 'Y'
true
when 'N'
false
else
nil
end
end
# prepare for database
def dump(value)
case value
when true
'Y'
when false
'N'
end
end
end # class BooleanChar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment