Module: Cerializable::Model::ClassMethods

Defined in:
lib/cerializable/model.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_cerializable(options = {}) ⇒ Object

‘acts_as_cerializable` is used to declare that a model uses Cerializable for serialization.

Unless a module is specified via the serialize_with option, the base model’s cerializer will attempt to include a module based on the model’s name.

For example, calling Comment.acts_as_cerializable without a serialize_with option will cause Cerializable to look for a CommentSerializer.

Calling Comment.acts_as_cerializable serialize_with: MySerializer will cause Cerializable to look for a MySerializer instead.



79
80
81
82
83
84
# File 'lib/cerializable/model.rb', line 79

def acts_as_cerializable(options = {})
  message = "'acts_as_cerializable' is deprecated and will be \
  removed from Cerializable in v1.0.0. Use 'cerializable' instead."
  Kernel.warn message
  cerializable(options)
end

#cerializable(options = {}) ⇒ Object



86
87
88
# File 'lib/cerializable/model.rb', line 86

def cerializable(options = {})
  Cerializable.setup(options.merge(base: self))
end