ginjo / rfm

FileMaker to Ruby adapter.
MIT License
45 stars 22 forks source link

Added field converter feature #8

Open smartacus opened 12 years ago

smartacus commented 12 years ago

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 commented 12 years ago

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 commented 10 years ago

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

ginjo commented 10 years ago

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.