#611 ✓resolved
Marcel

Rich types based on String do prepend "--- "

Reported by Marcel | January 29th, 2010 @ 04:38 PM | in Hobo 1.0 - Final

Trying to implement a subtype of String, after editing this rich-type field, the value is prefixed with "--- " and appended a trailing newline in the database.

This even happens on a newly created project using the LoudText example provided in http://cookbook.hobocentral.net/manual/hobofields

MacOSX 10.6.2, Ruby 1.8.7, Rails 2.3.5, Hobo 0.9.106

Comments and changes to this ticket

  • Bryan Larsen

    Bryan Larsen January 29th, 2010 @ 09:22 PM

    To get it to work, inherit directly from String rather than DelegateClass(String).

    I know that DelegateClass is required for some rich types, but I can't remember why. I'll update the documentation.

  • Bryan Larsen

    Bryan Larsen January 30th, 2010 @ 02:57 PM

    • Milestone set to Hobo 1.0 - Final
    • Tag changed from rich-types to documentation, rich-types
    • Assigned user set to “Bryan Larsen”
  • Owen

    Owen January 30th, 2010 @ 03:33 PM

    Mmmm. Bryan, what would be the proper code to create a new Hobo field type called "list_of_values", or "value_list" that has the same behavior as enum_string:

    field do
    
      region :list_of_values('North','South",'East','West')
    
    end
    

    (or use symbols for the value list.)

    The term "List of Values" or "LOV" is very common in the BI world...

  • Matt Jones

    Matt Jones January 30th, 2010 @ 05:10 PM

    I'll have to poke around the old archives, but I believe the DelegateClass stuff is needed for types that don't have a proper constructor (DateTime is one; Fixnum is another).

    Re: the list_of_values thing, you could just alias enum_string to list_of_values:

    HoboFields::FieldDeclarationDsl.class_eval { alias :list_of_values :enum_string }
    

    That will get you the behavior you've shown (minus the : on list_of_values)

    On a semi-related note - should we register the name passed with :name to EnumString with register_type? It would seem pretty logical, and make using named enum_strings even easier.

  • Owen

    Owen January 30th, 2010 @ 05:39 PM

    Thanks, Matt. That would be cool...

  • Bryan Larsen

    Bryan Larsen February 18th, 2010 @ 09:38 PM

    • State changed from “new” to “resolved”

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

Referenced by

Pages