Sha256: 8bab78c27b5b6a715688a785f17a89b921be2abcee20d4614a361fe6cf5f6090
Contents?: true
Size: 772 Bytes
Versions: 15
Compression:
Stored size: 772 Bytes
Contents
module NxtSupport module PreprocessAttributes extend ActiveSupport::Concern class_methods do attr_reader :nxt_preprocessors def preprocess_attributes(*attributes, **options) attributes_to_process = if attributes.any? attributes.map(&:to_sym) else column_names.map(&:to_sym) end @nxt_preprocessors ||= [] @nxt_preprocessors << NxtSupport::Preprocessor.new(attributes_to_process, options) end end included do before_validation do |record| nxt_preprocessors.each do |preprocessor| preprocessor.process(record) end end end private def nxt_preprocessors self.class.nxt_preprocessors end end end
Version data entries
15 entries across 15 versions & 1 rubygems