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.
this allows attributes to work for our uses, but not put them into the
public api

this addresses issues like ManageIQ#18130
  • Loading branch information
kbrock committed Oct 6, 2020
1 parent 4c1e528 commit c77d704
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 c77d704

Please sign in to comment.