mercredi 3 août 2016

determine if attribute has been serialized rails

I'm have a rails 3.2 app that has a class with:

class Element
  serialize :body
end

In the code how do I inspect the attribute to determine if the field is just text or is serialized? Then if serialized I need to know if it has

  serialize :body
  # vs
  serialize :body, Hash
  # vs
  serialize :body, Array

NOTE: I need to go from Element.new to an object with the correct type. I'm not just grabbing this object from the DB. Doing Element.new the field will be nil

Aucun commentaire:

Enregistrer un commentaire