Sha256: 00345700e20fcab32adee23a3b44549df0b08862d7fe2b13620deb4c3e485c90
Contents?: true
Size: 829 Bytes
Versions: 2
Compression:
Stored size: 829 Bytes
Contents
# frozen_string_literal: true require "invisible_record/helper" module InvisibleRecord # Add invisible behavior to an ActiveRecord Model module Model def acts_as_invisible(**options) options.deep_symbolize_keys! @_deleted_timestamp_attr = options[:deleted_timestamp_attribute] || "deleted_at" raise "Only call acts_as_invisible once per model" if respond_to?(:invisible_record_model?) class_eval do class << self def invisible_record_model? true end def without_deleted where(@_deleted_timestamp_attr => nil) end end Helper.define_hidden_attributes self, deleted_ts_attr: @_deleted_timestamp_attr Helper.define_actions self, deleted_ts_attr: @_deleted_timestamp_attr end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
invisible_record-0.1.5 | lib/invisible_record/model.rb |
invisible_record-0.1.4 | lib/invisible_record/model.rb |