Sha256: 94306c8b3ae5a632da5c45fb4e4188b1c713f1001c7e122ab579c6c7c4585ef6
Contents?: true
Size: 594 Bytes
Versions: 8
Compression:
Stored size: 594 Bytes
Contents
# frozen_string_literal: true class ActWithFlags::Admin attr_reader :clears def clear_at_save(*flags) flags.each { |name| add_to_clear_mask(name) } clears.each { |orig, mask| before_save(orig, mask) } @clears = {} end private def add_to_clear_mask(name) _model, orig, _pos = location(name).values mask = @clears[orig] || 0 mask |= 1 << position(name) @clears[orig] = mask end def before_save(orig, mask) model.class_eval %( before_save do |row| row.#{orig} &= ~#{mask} end ), __FILE__, __LINE__ - 4 end end
Version data entries
8 entries across 8 versions & 1 rubygems