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

Returns a new instance of AllowOnlyMongoidFields.



8
9
10
# File 'lib/clone_kit/rules/allow_only_mongoid_fields.rb', line 8

def initialize(model_klass)
  self.model_klass = model_klass
end

Instance Method Details

#fix(_old_id, attributes) ⇒ Object



12
13
14
# File 'lib/clone_kit/rules/allow_only_mongoid_fields.rb', line 12

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