Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added field converter feature #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

smartacus
Copy link

Added a converters configuration option allowing custom conversion of values in resultsets. A hash of field/lambda pairs is assigned to the converters configuration key to enable the feature.

As an example, you could specify that the 'logincount' field in this User model should be returned as an integer:

class User < Rfm::Base
  config :layout => 'my_user_layout'
  config :converters => {
    'logincount' => lambda { |f| f.to_i }
  }
end

@ginjo
Copy link
Owner

ginjo commented Oct 7, 2012

I've been working on a huge Rails project involving Rfm, and I've run into some obscure and not-so-obscure data conversion issues, in both directions (read and write). I've patched the issues in my project but haven't addressed this in Rfm yet. When I get a chance, I'll review my code and this request and see if I can put everything together.

@emptyflask
Copy link

@ginjo: any news on this? Looks like a nice feature...

@ginjo
Copy link
Owner

ginjo commented Aug 3, 2014

I've been saving this one until the I get the new parsing engine settled down. I'll have to work this request into the new record & field building process. Not a big deal, but I want to make sure it all fits together nicely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants