Skip to content

Commit

Permalink
Cleanup seed_from_array product feature things
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Jul 22, 2019
1 parent 7b1f5d2 commit ee5fa62
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/miq_user_role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ def self.seed
end

def self.seed_from_array(roles, array, merge_features = false)
features = MiqProductFeature.all
array.each do |hash|
feature_ids = hash.delete(:miq_product_feature_identifiers)

hash[:miq_product_features] = MiqProductFeature.where(:identifier => feature_ids).to_a
hash[:miq_product_features] = features.select { |f| feature_ids.include?(f.identifier) }
role = roles[hash[:name]] ||= new(hash.except(:id))
new_role = role.new_record?
hash[:miq_product_features] &&= role.miq_product_features if !new_role && merge_features
unless role.settings.nil? # Makse sure existing settings are merged in with the new ones.
unless role.settings.nil? # Make sure existing settings are merged in with the new ones.
new_settings = hash.delete(:settings) || {}
role.settings.merge!(new_settings)
end
Expand Down

0 comments on commit ee5fa62

Please sign in to comment.