module ZeroDowntime::Deprecatable::ClassMethods
Public Instance Methods
deprecate_column(column_name, options={})
click to toggle source
deprecate a given column so it will be ignore by activerecord we can remove it once the deprecation is deployed
# File lib/zero_downtime/deprecatable.rb, line 48 def deprecate_column(column_name, options={}) deprecate_column_reader(column_name, options) deprecate_column_writer(column_name) override_attribute_methods self.deprecated_columns ||= [] deprecated_columns << column_name.to_s end
Private Instance Methods
deprecate_column_reader(column_name, options)
click to toggle source
# File lib/zero_downtime/deprecatable.rb, line 68 def deprecate_column_reader(column_name, options) if options[:nil] define_method(column_name) do nil end else define_method(column_name) do fail DeprecatedColumn, "attempted to read #{column_name}" end end end
deprecate_column_writer(column_name)
click to toggle source
# File lib/zero_downtime/deprecatable.rb, line 80 def deprecate_column_writer(column_name) define_method("#{column_name}=") do |_| fail DeprecatedColumn, "attempted to write #{column_name}" end end
override_attribute_methods()
click to toggle source
# File lib/zero_downtime/deprecatable.rb, line 59 def override_attribute_methods return false if @attribute_methods_overriden class_eval do prepend AttributesWithDeprecations end @attribute_methods_overriden = true end