Sha256: a11d77843619489bf72de5f2d16228c0b6f6d5f86c9bb9abe5380f1fcb1ce17f
Contents?: true
Size: 1.21 KB
Versions: 3
Compression:
Stored size: 1.21 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) base.class_attribute :modis_connection base.modis_connection = :default 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
modis-4.3.2 | lib/modis/model.rb |
modis-4.3.1 | lib/modis/model.rb |
modis-4.3.0 | lib/modis/model.rb |