Class: CloneKit::Rules::AllowOnlyMongoidFields

Inherits:
CloneKit::Rule show all
Defined in:
lib/clone_kit/rules/allow_only_mongoid_fields.rb

Overview

The purpose of this rule is to only include attributes that are presently defined on the model (and its embedded models)

Instance Attribute Summary

Attributes inherited from CloneKit::Rule

#id_generator

Instance Method Summary collapse

Constructor Details

#initialize(model_klass) ⇒ AllowOnlyMongoidFields



10
11
12
# File 'lib/clone_kit/rules/allow_only_mongoid_fields.rb', line 10

def initialize(model_klass)
  self.model_klass = model_klass
end

Instance Method Details

#fix(_old_id, attributes) ⇒ Object



14
15
16
# File 'lib/clone_kit/rules/allow_only_mongoid_fields.rb', line 14

def fix(_old_id, attributes)
  slice_allowed!(polymorphic_class(model_klass.to_s, attributes), attributes)
end