Sha256: f0d81ec2ba164cd1490de03e8651a8c3be949fa16736eaa729979935ab8ff2f6

Contents?: true

Size: 829 Bytes

Versions: 5

Compression:

Stored size: 829 Bytes

Contents

module Mobility
  module Backend
=begin

Dirty tracking for Mobility attributes. See class-specific implementations for
details.

@see Mobility::Backend::ActiveModel::Dirty
@see Mobility::Backend::Sequel::Dirty

=end
    module Dirty
      # @param model_class Class of model this backend is defined on.
      # @return [Backend]
      # @raise [ArgumentError] if model class does not support dirty tracking
      def self.for(model_class)
        model_class ||= Object
        if Loaded::ActiveRecord && model_class.ancestors.include?(::ActiveModel::Dirty)
          Backend::ActiveModel::Dirty
        elsif Loaded::Sequel && model_class < ::Sequel::Model
          Backend::Sequel::Dirty
        else
          raise ArgumentError, "#{model_class.to_s} does not support Dirty module."
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mobility-0.1.4 lib/mobility/backend/dirty.rb
mobility-0.1.3 lib/mobility/backend/dirty.rb
mobility-0.1.2 lib/mobility/backend/dirty.rb
mobility-0.1.1 lib/mobility/backend/dirty.rb
mobility-0.1.0 lib/mobility/backend/dirty.rb