#387 ✓resolved
Will Prater

Need to add dump to Boolean type

Reported by Will Prater | June 14th, 2008 @ 10:54 PM

We need to add a dump method to the Boolean type. Since Boolean is a @custom property, typecast never gets called.

I suppose I could use TrueClass as my property type in my model, but I didn't :).

I used the same line of code from typecast into the Boolean dump method

module DataMapper

module Types

class Boolean < DataMapper::Type

primitive TrueClass

def self.dump(value, property)

%w[ true 1 t ].include?(value.to_s.downcase)

end

end # class Boolean

end # module Types

end # module DataMapper

Comments and changes to this ticket

  • Sam Smoot

    Sam Smoot June 16th, 2008 @ 01:33 PM

    Actually, CustomTypes that don't respond_to dump/load should default to #primitive assignment.

    So no need for dump/load, it'll just slow things down.

    But the specs might need to be improved to verify they're using the #primitive and not the #type during type-casting.

    So we'll put this one down for review. Needs spec confirming Boolean properties are type-cast properly.

  • Will Prater

    Will Prater June 16th, 2008 @ 02:27 PM

    The primitive will not perform the needed voodoo for allowing 1, t, true for True Type though?

  • Bernerd Schaefer

    Bernerd Schaefer July 14th, 2008 @ 09:49 AM

    • State changed from “new” to “resolved”
    • Tag set to bug

    This should be resolved in edge. I recently made some changes so that Property.typecast(value) first calls type.typecast() if it has it, and then typecasts according to primitive:

    if primitive == TrueClass then %w[ true 1 t ].include?(value.to_s.downcase)

    Can you let me know if this is still an issue?

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Tags

Pages