Sha256: 1c0dd299ab01f61d0ace7ef582b306997d70b2789b1a28f6bf11545feaee4195

Contents?: true

Size: 952 Bytes

Versions: 4

Compression:

Stored size: 952 Bytes

Contents

module Sequel
  module Plugins
    # The ActiveModel plugin makes Sequel::Model objects the
    # pass the ActiveModel::Lint tests, which should
    # hopefully mean full ActiveModel compliance.  This should
    # allow the full support of Sequel::Model objects in Rails 3.
    module ActiveModel
      module InstanceMethods
        # Record that an object was destroyed, for later use by
        # destroyed?
        def after_destroy
          super
          @destroyed = true
        end
        
        # Whether the object was destroyed by destroy.  Not true
        # for objects that were deleted.
        def destroyed?
          @destroyed == true
        end
        
        # An alias for new?
        def new_record?
          new?
        end

        # With the ActiveModel plugin, Sequel model objects are already
        # compliant, so this returns self.
        def to_model
          self
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sequel-3.8.0 lib/sequel/plugins/active_model.rb
sequel-3.7.0 lib/sequel/plugins/active_model.rb
sequel-3.6.0 lib/sequel/plugins/active_model.rb
sequel-3.5.0 lib/sequel/plugins/active_model.rb