Module: HierarchySnapshot::ActiveRecord::ClassMethods
- Defined in:
- lib/hierarchy_snapshot/active_record.rb
Instance Method Summary collapse
Instance Method Details
#keep_hierarchy_snapshot(&bl) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/hierarchy_snapshot/active_record.rb', line 4 def keep_hierarchy_snapshot(&bl) unless respond_to? :hierarchy_snapshot_save send :include, InstanceMethods end after_create :hierarchy_snapshot_save after_update :hierarchy_snapshot_save class_attribute :hierarchy_snapshot_config attr_accessor :snapshot_user self.hierarchy_snapshot_config = Configuration.new(true).tap{|c| c.instance_eval(&bl)} end |
#without_snapshot ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/hierarchy_snapshot/active_record.rb', line 17 def without_snapshot old = Thread.current[:skip_hierarchy_snapshot] begin Thread.current[:skip_hierarchy_snapshot] = true return yield ensure Thread.current[:skip_hierarchy_snapshot] = old end end |