Method: Togls::FeatureRepository#validate_feature_data

Defined in:
lib/togls/feature_repository.rb

#validate_feature_data(feature_data) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/togls/feature_repository.rb', line 54

def validate_feature_data(feature_data)
  if feature_data.nil?
    Togls.logger.warn("None of the feature repository drivers claim to have the feature")
    raise Togls::RepositoryFeatureDataInvalid, "None of the feature repository drivers claim to have the feature"
  end

  ['key', 'description', 'target_type'].each do |k|
    if !feature_data.has_key? k
      Togls.logger.warn("One of the feature repository drivers returned feature data that is missing the '#{k}'")
      raise Togls::RepositoryFeatureDataInvalid, "One of the feature repository drivers returned feature data that is missing the '#{k}'"
    end

    if !feature_data[k].is_a?(String)
      Togls.logger.warn("One of the feature repository drivers returned feature data with '#{k}' not being a string")
      raise Togls::RepositoryFeatureDataInvalid, "One of the feature repository drivers returned feature data with '#{k}' not being a string"
    end
  end
end