Class: Gitlab::ImportExport::AttributeCleaner
- Inherits:
-
Object
- Object
- Gitlab::ImportExport::AttributeCleaner
- Defined in:
- lib/gitlab/import_export/attribute_cleaner.rb
Constant Summary collapse
- ALLOWED_REFERENCES =
[ *Gitlab::ImportExport::Project::RelationFactory::PROJECT_REFERENCES, *Gitlab::ImportExport::Project::RelationFactory::USER_REFERENCES, 'group_id', 'commit_id', 'discussion_id', 'custom_attributes' ].freeze
- PROHIBITED_REFERENCES =
Regexp.union( /\Acached_markdown_version\Z/, /_id\Z/, /_ids\Z/, /_html\Z/, /attributes/, /\Aremote_\w+_(url|urls|request_header)\Z/ # carrierwave automatically creates these attribute methods for uploads ).freeze
Class Method Summary collapse
Instance Method Summary collapse
- #clean ⇒ Object
-
#initialize(relation_hash:, relation_class:, excluded_keys: []) ⇒ AttributeCleaner
constructor
A new instance of AttributeCleaner.
Constructor Details
#initialize(relation_hash:, relation_class:, excluded_keys: []) ⇒ AttributeCleaner
Returns a new instance of AttributeCleaner.
27 28 29 30 31 |
# File 'lib/gitlab/import_export/attribute_cleaner.rb', line 27 def initialize(relation_hash:, relation_class:, excluded_keys: []) @relation_hash = relation_hash @relation_class = relation_class @excluded_keys = excluded_keys end |
Class Method Details
.clean(*args, **kwargs) ⇒ Object
23 24 25 |
# File 'lib/gitlab/import_export/attribute_cleaner.rb', line 23 def self.clean(*args, **kwargs) new(*args, **kwargs).clean end |
Instance Method Details
#clean ⇒ Object
33 34 35 36 37 |
# File 'lib/gitlab/import_export/attribute_cleaner.rb', line 33 def clean @relation_hash.reject do |key, _value| prohibited_key?(key) || !@relation_class.attribute_method?(key) || excluded_key?(key) end.except('id') end |