Refactor for lazy

e6ad31d

> On Nov 18, 2014, at 3:03 PM, Fabio Kreusch <notifications@github.com> wrote:
> 
> In lib/crypt_keeper/model.rb:
> 
> >  
> >          crypt_keeper_fields.each do |field|
> > -          serialize field, encryptor_klass.new(crypt_keeper_options).
> > -            extend(::CryptKeeper::Helper::Serializer)
> > +          define_method "#{field}" do
> > +            value = read_attribute(field)
> > +
> > +            if value.present?
> > +              force_string_encoding self.class.encryptor_klass_instance.decrypt(value).to_s
> Does this work with new records? E.g.:
> 
> m = Model.new(encrypted_field: "somevalue")
> m.encrypted_field.should == "somevalue"
> —
> Reply to this email directly or view it on GitHub <https://github.com/jmazzi/crypt_keeper/pull/89/files#r20533767>.
>