Module: ActiveModel::Embedding::Document
- Defined in:
- lib/active_model/embedding/document.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/active_model/embedding/document.rb', line 6 def self.included(klass) klass.class_eval do extend ClassMethods extend ActiveModel::Callbacks define_model_callbacks :save include ActiveModel::Model include ActiveModel::Attributes include ActiveModel::Serializers::JSON include Embedding::Associations attribute :id, :integer def save run_callbacks :save do return false unless valid? self.id = object_id unless persisted? true end end def persisted? id.present? end def ==(other) attributes == other.attributes end end end |