Class: Wallaby::ModelClassFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/services/wallaby/model_class_filter.rb

Overview

Fitler the model classes using

Class Method Summary collapse

Class Method Details

.execute(all:, allowlisted:, denylisted:) ⇒ Object

Parameters:

  • all (Array<Class>)
  • allowlisted (Array<Class>)
  • denylisted (Array<Class>)

Raises:



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/services/wallaby/model_class_filter.rb', line 10

def execute(all:, allowlisted:, denylisted:)
  invalid, valid =
    allowlisted.present? ? [allowlisted - all, allowlisted] : [denylisted - all, all - denylisted]
  return valid if invalid.blank?

  raise InvalidError, "    Wallaby can't handle these models: \#{invalid.map(&:name).to_sentence}.\n    If it's set via controller_class.models= or controller_class.models_to_exclude=,\n    please remove them from the list.\n\n    Or they can be added to Custom model list as below, and custom implementation will be required:\n\n      Wallaby.config do |config|\n        config.custom_models = \#{invalid.map(&:name).join ', '}\n      end\n  INSTRUCTION\nend\n"