Class: Gitlab::ImportExport::AttributesPermitter
- Inherits:
-
Object
- Object
- Gitlab::ImportExport::AttributesPermitter
- Defined in:
- lib/gitlab/import_export/attributes_permitter.rb
Constant Summary collapse
- DISABLED_RELATION_NAMES =
We want to use AttributesCleaner for these relations instead, in the future this should be removed to make sure we are using AttributesPermitter for every imported relation.
%i[author issuable_sla].freeze
Instance Attribute Summary collapse
-
#permitted_attributes ⇒ Object
readonly
Returns the value of attribute permitted_attributes.
Instance Method Summary collapse
-
#initialize(config: ImportExport::Config.new.to_h) ⇒ AttributesPermitter
constructor
A new instance of AttributesPermitter.
- #permit(relation_sym, relation_hash) ⇒ Object
- #permitted_attributes_defined?(relation_sym) ⇒ Boolean
- #permitted_attributes_for(relation_sym) ⇒ Object
Constructor Details
#initialize(config: ImportExport::Config.new.to_h) ⇒ AttributesPermitter
Returns a new instance of AttributesPermitter.
49 50 51 52 53 54 55 |
# File 'lib/gitlab/import_export/attributes_permitter.rb', line 49 def initialize(config: ImportExport::Config.new.to_h) @config = config @attributes_finder = Gitlab::ImportExport::AttributesFinder.new(config: @config) @permitted_attributes = {} build_permitted_attributes end |
Instance Attribute Details
#permitted_attributes ⇒ Object (readonly)
Returns the value of attribute permitted_attributes.
43 44 45 |
# File 'lib/gitlab/import_export/attributes_permitter.rb', line 43 def permitted_attributes @permitted_attributes end |
Instance Method Details
#permit(relation_sym, relation_hash) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/gitlab/import_export/attributes_permitter.rb', line 57 def permit(relation_sym, relation_hash) permitted_attributes = permitted_attributes_for(relation_sym) relation_hash.select do |key, _| permitted_attributes.include?(key.to_sym) end end |
#permitted_attributes_defined?(relation_sym) ⇒ Boolean
69 70 71 |
# File 'lib/gitlab/import_export/attributes_permitter.rb', line 69 def permitted_attributes_defined?(relation_sym) DISABLED_RELATION_NAMES.exclude?(relation_sym) && @attributes_finder.included_attributes.key?(relation_sym) end |
#permitted_attributes_for(relation_sym) ⇒ Object
65 66 67 |
# File 'lib/gitlab/import_export/attributes_permitter.rb', line 65 def permitted_attributes_for(relation_sym) @permitted_attributes[relation_sym] || [] end |