Class: Kiba::Extend::Utils::Lookup::CriteriaChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/kiba/extend/utils/lookup/criteria_checker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(check_type:, config:, row:, mergerow: {}, sep: nil) ⇒ CriteriaChecker

Returns a new instance of CriteriaChecker.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/kiba/extend/utils/lookup/criteria_checker.rb', line 10

def initialize(check_type:, config:, row:, mergerow: {}, sep: nil)
  @check_type = check_type
  @config = config
  @row = row
  @mergerow = mergerow
  @type = @config[:type] || :all
  bool = []

  @config[:fieldsets].each do |set|
    bool << Lookup::SetChecker.new(
      check_type: @check_type,
      set: set,
      row: @row,
      mergerow: @mergerow,
      sep: sep
    ).result
  end

  case @type
  when :any
    @result = bool.any?
  when :all
    @result = !bool.any?(false)
  end
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



8
9
10
# File 'lib/kiba/extend/utils/lookup/criteria_checker.rb', line 8

def result
  @result
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/kiba/extend/utils/lookup/criteria_checker.rb', line 8

def type
  @type
end