Class: PartializerConfig::PartialFunctions

Inherits:
Struct
  • Object
show all
Defined in:
lib/ceedling/partials/partializer_config.rb

Overview

Holds function-level extraction config for tests or mocks within a Partial. type -- :public, :private, or :accumulate (additions-driven); nil if unset additions -- function names to explicitly include subtractions -- function names to explicitly exclude (illegal with ACCUMULATE)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type: nil, additions: [], subtractions: []) ⇒ PartialFunctions

Returns a new instance of PartialFunctions.



40
41
42
# File 'lib/ceedling/partials/partializer_config.rb', line 40

def initialize(type: nil, additions: [], subtractions: [])
  super
end

Instance Attribute Details

#additionsObject

Returns the value of attribute additions

Returns:

  • (Object)

    the current value of additions



39
40
41
# File 'lib/ceedling/partials/partializer_config.rb', line 39

def additions
  @additions
end

#subtractionsObject

Returns the value of attribute subtractions

Returns:

  • (Object)

    the current value of subtractions



39
40
41
# File 'lib/ceedling/partials/partializer_config.rb', line 39

def subtractions
  @subtractions
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



39
40
41
# File 'lib/ceedling/partials/partializer_config.rb', line 39

def type
  @type
end

Instance Method Details

#present?Boolean

Returns true if this PartialFunctions entry has enough configuration to be processed. Used to gate downstream work: a nil type means the feature is disabled; an ACCUMULATE type with no additions has no functions to include; all other cases are meaningful.

Returns:

  • (Boolean)


47
48
49
50
51
52
53
54
55
56
# File 'lib/ceedling/partials/partializer_config.rb', line 47

def present?
  # Feature is disabled for this test/mock side of the module
  return false if type.nil?
  # ACCUMULATE starts empty and relies entirely on explicit additions; without any,
  # there is nothing to include, so the config has no effect
  return false if type == ACCUMULATE && additions.empty?
  # PUBLIC, PRIVATE: always have a base set of functions to filter
  # DEDUCT: starts with all functions; zero subtractions is valid ("include everything")
  return true
end