Sha256: d0cb9835cdaa4f3d148ab98a26a87f139e2e0985d99bb0a7458f95397f2dfe44

Contents?: true

Size: 734 Bytes

Versions: 6

Compression:

Stored size: 734 Bytes

Contents

module Saviour
  NoActiveRecordDetected = Class.new(StandardError)

  module Model
    def self.included(klass)
      Integrator.new(klass, PersistenceLayer).setup!

      klass.class_eval do
        raise(NoActiveRecordDetected, "Error: ActiveRecord not detected in #{self}") unless self.ancestors.include?(ActiveRecord::Base)

        after_destroy { Saviour::LifeCycle.new(self, PersistenceLayer).delete! }
        after_save { Saviour::LifeCycle.new(self, PersistenceLayer).save! }
        validate { Saviour::Validator.new(self).validate! }
      end
    end

    def reload
      self.class.attached_files.each do |attach_as|
        instance_variable_set("@__uploader_#{attach_as}", nil)
      end
      super
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
saviour-0.4.5 lib/saviour/model.rb
saviour-0.4.4 lib/saviour/model.rb
saviour-0.4.3 lib/saviour/model.rb
saviour-0.4.2 lib/saviour/model.rb
saviour-0.4.1 lib/saviour/model.rb
saviour-0.4.0 lib/saviour/model.rb