Module: Modis::Model
- Defined in:
- lib/modis/model.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/modis/model.rb', line 5 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 |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
45 46 47 |
# File 'lib/modis/model.rb', line 45 def ==(other) super || other.instance_of?(self.class) && id.present? && other.id == id end |
#initialize(record = nil, options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/modis/model.rb', line 34 def initialize(record = nil, = {}) apply_defaults set_sti_type assign_attributes(record) if record changes_applied return unless .key?(:new_record) instance_variable_set('@new_record', [:new_record]) end |