Sha256: 4a72effcb0e248489bcbb95b5b355fd8d171c1989c105ff9f94f77ddd9359202
Contents?: true
Size: 1.6 KB
Versions: 6
Compression:
Stored size: 1.6 KB
Contents
require_relative 'crud_logger' require_relative 'constants' module Rails module Crud module Tools class CrudOperations include Singleton attr_accessor :table_operations, :logs def initialize @table_operations = Hash.new do |hash, method| hash[method] = Hash.new do |h, key| h[key] = Hash.new do |hh, table| hh[table] = [] end end end end def add_operation(method, key, table_name, operation) # @table_operations[method]が存在しない場合は初期化 @table_operations[method] ||= {} # @table_operations[method][key]が存在しない場合は初期化 @table_operations[method][key] ||= {} # @table_operations[method][key][table_name]が存在しない場合は初期化 @table_operations[method][key][table_name] ||= [] @table_operations[method][key][table_name] << operation unless @table_operations[method][key][table_name].include?(operation) end def log_operations(method, key) CrudLogger.logger.info "\nSummary: Method: #{method}, Key: #{key}" @table_operations[method][key].each do |table_name, operations| CrudLogger.logger.info "#{table_name} - #{operations.join(', ')}" end end def table_operations_present?(method, key) return false if @table_operations[method].nil? return false if @table_operations[method][key].nil? !@table_operations[method][key].empty? end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems