Sha256: 7ce7dfb6cca76d74b461f2b16c116e9b59af30400b6f8f33091c2cfc319fb69b
Contents?: true
Size: 1.12 KB
Versions: 8
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true module Modis module Model def self.included(base) base.instance_eval do include ActiveModel::Dirty include ActiveModel::Validations include ActiveModel::Serialization extend ActiveModel::Naming extend ActiveModel::Callbacks define_model_callbacks :save, :create, :update, :destroy include Modis::Errors include Modis::Transaction include Modis::Persistence include Modis::Finder include Modis::Attribute include Modis::Index base.extend(ClassMethods) end end module ClassMethods def inherited(child) super bootstrap_sti(self, child) end end def initialize(record = nil, options = {}) apply_defaults set_sti_type assign_attributes(record) if record changes_applied return unless options.key?(:new_record) instance_variable_set('@new_record', options[:new_record]) end def ==(other) super || other.instance_of?(self.class) && id.present? && other.id == id end alias eql? == end end
Version data entries
8 entries across 8 versions & 1 rubygems