module ActiveRecord::AttributeDecorators::ClassMethods
def add_user_provided_columns(*)
def add_user_provided_columns(*) super.map do |column| decorated_type = attribute_type_decorations.apply(column.name, column.cast_type) column.with_type(decorated_type) end end
def decorate_attribute_type(column_name, decorator_name, &block)
def decorate_attribute_type(column_name, decorator_name, &block) matcher = ->(name, _) { name == column_name.to_s } key = "_#{column_name}_#{decorator_name}" decorate_matching_attribute_types(matcher, key, &block) end
def decorate_matching_attribute_types(matcher, decorator_name, &block)
def decorate_matching_attribute_types(matcher, decorator_name, &block) clear_caches_calculated_from_columns decorator_name = decorator_name.to_s # Create new hashes so we don't modify parent classes self.attribute_type_decorations = attribute_type_decorations.merge(decorator_name => [matcher, block]) end