module InventoryRefresh::InventoryCollection::Helpers::QuestionsHelper

Public Instance Methods

check_changed?() click to toggle source

@return [Boolean] true means we want to call .changed? on every ActiveRecord object before saving it

# File lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb, line 8
def check_changed?
  check_changed
end
complete?() click to toggle source

@return [Boolean] true means the data is not complete, leading to only creating and updating data

# File lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb, line 19
def complete?
  complete
end
create_allowed?() click to toggle source

@return [Boolean] true means we will delete/soft-delete data

# File lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb, line 34
def create_allowed?
  !update_only?
end
create_only?() click to toggle source

@return [Boolean] true means that only create of new data is allowed

# File lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb, line 39
def create_only?
  create_only
end
data_collection_finalized?() click to toggle source

@return [Boolean] true if no more data will be added to this InventoryCollection object, that usually happens

after the parsing step is finished
# File lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb, line 75
def data_collection_finalized?
  data_collection_finalized
end
delete_allowed?() click to toggle source

@return [Boolean] true means we will delete/soft-delete data

# File lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb, line 29
def delete_allowed?
  complete? && !update_only?
end
noop?() click to toggle source

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.

@return [Boolean] true if processing of this InventoryCollection object would lead to no operations.

# File lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb, line 83
def noop?
  data.blank? && custom_save_block.nil? && skeletal_primary_index.blank?
end
saveable?() click to toggle source

@return [Boolean] true if all dependencies have all data persisted

# File lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb, line 49
def saveable?
  dependencies.all?(&:saved?)
end
saved?() click to toggle source

@return [Boolean] true if the whole InventoryCollection object has all data persisted

# File lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb, line 44
def saved?
  saved
end
supports_column?(column_name) click to toggle source

@param column_name [Symbol, String] @return [Boolean] true if the model_class supports given column

# File lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb, line 61
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?() click to toggle source

@return [Boolean] true if the model_class supports STI

# File lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb, line 54
def supports_sti?
  @supports_sti_cache = model_class&.column_names.to_a.include?("type") if @supports_sti_cache.nil?
  @supports_sti_cache
end
update_only?() click to toggle source

@return [Boolean] true means we want to only update data

# File lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb, line 24
def update_only?
  update_only
end
use_ar_object?() click to toggle source

@return [Boolean] true means we want to use ActiveRecord object for writing attributes and we want to perform

casting on all columns
# File lib/inventory_refresh/inventory_collection/helpers/questions_helper.rb, line 14
def use_ar_object?
  use_ar_object
end