#511 ✓not-applicable

[PATCH] Enum proxy methods [dm-types]

Reported by teamon | August 3rd, 2008 @ 09:39 PM

Lets say the model has property like this:

property :status, Enum[:not_added, :waiting, :accepted, :rejected], :proxy_methods => :the

the :proxy_methods option will automatically add to class like:

def self.the_accepted
  all(:status => :accepted)

Unfortunatelly there are some problems.

There is a need for prefix ('the' is not the best but i couldn`t find better) because some test fails without it. Also my 'implementation' is ugly (monkey patching Property class).

I`d like to just share the idea.

Comments and changes to this ticket

  • felix (xilef)

    felix (xilef) August 18th, 2008 @ 10:05 AM

    i like this.

    property :role, Enum[:user, :admin], :proxy_methods => :is

    would be handy.

  • Jonathan Stott (namelessjon)

    Jonathan Stott (namelessjon) December 12th, 2008 @ 01:12 PM

    • Assigned user changed from “Sam Smoot” to “Dan Kubb (dkubb)”
    • Tag changed from dm-more, suggestion to dm-more, dm-types, suggestion
    • State changed from “new” to “hold”
    • Title changed from “Enum proxy methods” to “[PATCH] Enum proxy methods [dm-types]”

    Dan, could you have a look over this?

    I think it could be applied to dm-types fairly easily, but it does add more complexity

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) December 13th, 2008 @ 12:00 PM

    • State changed from “hold” to “not-applicable”

    I think I'd rather see this in a separate plugin than a patch to dm-types' Enum property.

    It seems out of place to have something that is supposed to just be for adding custom types adding custom finders to the Models. This isn't consistent with any of the other types.

    Tymon, I'd suggest making a plugin in your github account, and then promoting it to the mailing list. If it receives widespread usage we can move it into the sam/dm-more plugin directory.

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