Class: ActiveRecordCompose::Model

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Attributes, ActiveModel::Model, AttributeQuerying, Callbacks, DelegateAttribute, Persistence, Validations
Defined in:
lib/active_record_compose/model.rb

Constant Summary

Constants included from DelegateAttribute

DelegateAttribute::Delegation

Instance Method Summary collapse

Methods included from Validations

#save, #save!, #valid?

Methods included from Persistence

#save, #save!, #update, #update!

Methods included from TransactionSupport

#id, #restore_transaction_record_state, #trigger_transactional_callbacks?

Methods included from DelegateAttribute

#attribute_names, #attributes

Constructor Details

#initialize(attributes = {}) ⇒ Model

Returns a new instance of Model.



22
23
24
# File 'lib/active_record_compose/model.rb', line 22

def initialize(attributes = {})
  super
end

Instance Method Details

#persisted?Boolean

Returns true if model is persisted.

By overriding this definition, you can control the callbacks that are triggered when a save is made. For example, returning false will trigger before_create, around_create and after_create, and returning true will trigger before_update, around_update and after_update.

Returns:

  • (Boolean)

    returns true if model is persisted.



33
# File 'lib/active_record_compose/model.rb', line 33

def persisted? = super