Skip to content

Commit

Permalink
Hide deprecated and duplicate attributes
Browse files Browse the repository at this point in the history
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to start using.

This allows attributes to still work, but just not be advertised on our public apis (i.e.: report builder and rest api). This allows 

This fixes ManageIQ#18130
This enables ManageIQ#20532
  • Loading branch information
kbrock committed Oct 6, 2020
1 parent 4c1e528 commit 9ac9668
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/models/mixins/deprecation_mixin.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
module DeprecationMixin
extend ActiveSupport::Concern

included do
catter :hidden_attributes
self.hidden_attributes = []
end

module ClassMethods
def visible_attribute_names
attribute_names - hidden_attributes
end

private

def deprecate_belongs_to(old_belongs_to, new_belongs_to)
Expand All @@ -18,6 +27,7 @@ def deprecate_belongs_to(old_belongs_to, new_belongs_to)
def deprecate_attribute(old_attribute, new_attribute)
deprecate_attribute_methods(old_attribute, new_attribute)
virtual_attribute(old_attribute, -> { type_for_attribute(new_attribute.to_s) })
hidden_attributes << old_attribute
end

def deprecate_attribute_methods(old_attribute, new_attribute)
Expand Down

0 comments on commit 9ac9668

Please sign in to comment.