Module: InventoryRefresh::InventoryCollection::Helpers::QuestionsHelper

Included in:
InventoryRefresh::InventoryCollection
Defined in:
lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb

Instance Method Summary collapse

Instance Method Details

#check_changed?Boolean



8
9
10
# File 'lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb', line 8

def check_changed?
  check_changed
end

#complete?Boolean



19
20
21
# File 'lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb', line 19

def complete?
  complete
end

#create_allowed?Boolean



34
35
36
# File 'lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb', line 34

def create_allowed?
  !update_only?
end

#create_only?Boolean



39
40
41
# File 'lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb', line 39

def create_only?
  create_only
end

#data_collection_finalized?Boolean



81
82
83
# File 'lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb', line 81

def data_collection_finalized?
  data_collection_finalized
end

#delete_allowed?Boolean



29
30
31
# File 'lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb', line 29

def delete_allowed?
  complete? && !update_only?
end

#delete_complement_noop?Boolean



105
106
107
# File 'lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb', line 105

def delete_complement_noop?
  all_manager_uuids.nil?
end

#noop?Boolean

True if processing of this InventoryCollection object would lead to no operations. Then we use this marker to stop processing of the InventoryCollector object very soon, to avoid a lot of unnecessary Db queries, etc.



94
95
96
97
# File 'lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb', line 94

def noop?
  # If this InventoryCollection doesn't do anything. it can easily happen for targeted/batched strategies.
  saving_noop? && delete_complement_noop?
end

#parallel_safe?Boolean



54
55
56
57
# File 'lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb', line 54

def parallel_safe?
  return @parallel_safe unless @parallel_safe.nil?
  @parallel_safe = %i[concurrent_safe concurrent_safe_batch].include?(saver_strategy)
end

#saveable?Boolean



49
50
51
# File 'lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb', line 49

def saveable?
  dependencies.all?(&:saved?)
end

#saved?Boolean



44
45
46
# File 'lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb', line 44

def saved?
  saved
end

#saving_noop?Boolean



100
101
102
# File 'lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb', line 100

def saving_noop?
  saving_targeted_parent_collection_noop? || saving_targeted_child_collection_noop? || saving_full_collection_noop?
end

#supports_column?(column_name) ⇒ Boolean



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb', line 67

def supports_column?(column_name)
  @supported_cols_cache ||= {}
  return @supported_cols_cache[column_name.to_sym] unless @supported_cols_cache[column_name.to_sym].nil?

  include_col = model_class&.column_names.to_a.include?(column_name.to_s)
  if %w[created_on created_at updated_on updated_at].include?(column_name.to_s)
    include_col &&= ActiveRecord::Base.record_timestamps
  end

  @supported_cols_cache[column_name.to_sym] = include_col
end

#supports_sti?Boolean



60
61
62
63
# File 'lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb', line 60

def supports_sti?
  return @supports_sti unless @supports_sti.nil?
  @supports_sti = model_class&.column_names.to_a.include?("type")
end

#targeted?Boolean



86
87
88
# File 'lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb', line 86

def targeted?
  targeted
end

#update_only?Boolean



24
25
26
# File 'lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb', line 24

def update_only?
  update_only
end

#use_ar_object?Boolean



14
15
16
# File 'lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb', line 14

def use_ar_object?
  use_ar_object
end