mustmodify / valuable

quick ruby modeling -- basically attr_accessor with default values, light-weight casting, and a constructor
http://valuable.mustmodify.com/
MIT License
72 stars 3 forks source link

custom formatter option #2

Closed TMaYaD closed 12 years ago

TMaYaD commented 12 years ago

Added custom formatter option so that users can use it along with custom classes

mustmodify commented 12 years ago

Thank you for submitting this patch. It's a feature I've wanted in the past, but could never come with with the right key. I'm still not wild about formatter, but I agree something needs to be done about it. I've sent out an email to some friends to see if they have any other suggestions. If not, we'll go with what you have.

Again, thanks for the patch, and I hope the gem is as useful for you as it has been for me.

jw

ps the other thing I was thinking about would be

has_value :date, :parse_with => 'Date.parse' or has_value :date, :parse_with => lambda {|atts| Date.parse(atts[:date])}


Johnathon Wright Web Application Consultant

wave: jw@mustmodify.com gtalk: jw@mustmodify.com skype: johnathonwright yahoo: johnathonewright cell: 337 326 3121

http://www.mustmodify.com/

On Tue, Nov 1, 2011 at 4:36 AM, TMaYaD < reply@reply.github.com>wrote:

Added custom formatter option so that users can use it along with custom classes

You can merge this Pull Request by running:

git pull https://github.com/LoonyBin/valuable master

Or you can view, comment on it, or merge it online at:

https://github.com/mustmodify/valuable/pull/2

-- Commit Summary --

  • added custom formatter option to has_value

-- File Changes --

M lib/valuable/utils.rb (4) M test/typical_test.rb (10)

-- Patch Links --

https://github.com/mustmodify/valuable/pull/2.patch https://github.com/mustmodify/valuable/pull/2.diff

Reply to this email directly or view it on GitHub: https://github.com/mustmodify/valuable/pull/2

TMaYaD commented 12 years ago

parse_with definitely sounds better if lambda's are also allowed. It should be a trivial change to do it like active record. I'll get around to it some time.

mustmodify commented 12 years ago

I find myself needing this on a current project, so I'm moving forward with it. I've put down some ideas about how it should work. I'm interested in your thoughts.

http://blog.mustmodify.com/pages/valuable-ruby-gem-parse-with-notes