Module: Mobility::Backend::Dirty

Defined in:
lib/mobility/backend/dirty.rb

Overview

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

Class Method Summary collapse

Class Method Details

.for(model_class) ⇒ Backend

Parameters:

  • model_class

    Class of model this backend is defined on.

Returns:

Raises:

  • (ArgumentError)

    if model class does not support dirty tracking



16
17
18
19
20
21
22
23
24
25
# File 'lib/mobility/backend/dirty.rb', line 16

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