Skip to content

Instantly share code, notes, and snippets.

@jzajpt
Created April 1, 2011 07:24
Show Gist options
  • Save jzajpt/897854 to your computer and use it in GitHub Desktop.
Save jzajpt/897854 to your computer and use it in GitHub Desktop.
# encoding: utf-8
require 'mongoid_typecast_attributes'
module Mongoid
module Document
include MongoidTypecastAttributes
end
end
# encoding: utf-8
module MongoidTypecastAttributes
extend ActiveSupport::Concern
def read_attribute(name)
access = name.to_s
value = @attributes[access]
typed_value = fields.has_key?(access) ? fields[access].get(value) : value
accessed(access, typed_value)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment