Class: Wallaby::Configuration::Models

Inherits:
Object
  • Object
show all
Defined in:
lib/wallaby/configuration/models.rb

Overview

Configuration for the model classes that Wallaby should handle > NOTE: In ‘devlopment` environment, Rails recreates module/class > constants on reload event. If we cache constants, they will become > stale and raise conflicts. > Hence, we need to storing name strings instead of constants.

Instance Method Summary collapse

Instance Method Details

#exclude(*models) ⇒ Object

Specify the model classes that user wants to exclude

Parameters:

  • models (Array<Class>)


22
23
24
# File 'lib/wallaby/configuration/models.rb', line 22

def exclude(*models)
  @excludes = Array(models).flatten.map(&:to_s)
end

#excludesArray<Class>

Returns the list of models that user has configured.

Returns:

  • (Array<Class>)

    the list of models that user has configured



27
28
29
# File 'lib/wallaby/configuration/models.rb', line 27

def excludes
  (@excludes ||= []).map(&:constantize)
end

#presenceArray<Class>?

Returns the list of models that user has configured.

Returns:

  • (Array<Class>, nil)

    the list of models that user has configured



16
17
18
# File 'lib/wallaby/configuration/models.rb', line 16

def presence
  (@models ||= []).map(&:constantize)
end

#set(*models) ⇒ Object

Specify the model classes that Wallaby should handle

Parameters:

  • models (Array<Class>)


11
12
13
# File 'lib/wallaby/configuration/models.rb', line 11

def set(*models)
  @models = Array(models).flatten.map(&:to_s)
end