Class: ActiveRecordCompose::Model
- Inherits:
-
Object
- Object
- ActiveRecordCompose::Model
- Includes:
- ActiveModel::Model, Attributes, Inspectable, Persistence, TransactionSupport, Validations
- Defined in:
- lib/active_record_compose/model.rb
Overview
This is the core class of ActiveRecordCompose.
By defining subclasses of this model, you can use ActiveRecordCompose functionality in your application.
It has the basic functionality of ActiveModel::Model and ActiveModel::Attributes,
and also provides aggregation of multiple models and atomic updates through transaction control.
Instance Method Summary collapse
-
#id ⇒ Object
Returns the ID value.
-
#initialize(attributes = {}) ⇒ Model
constructor
A new instance of Model.
-
#models ⇒ ActiveRecordCompose::ComposedCollection
private
Returns a collection of model elements to encapsulate.
Methods included from Inspectable
filter_attributes, filter_attributes=, #inspect, #pretty_print
Methods included from Attributes
attribute_names, #attribute_names, #attributes, delegate_attribute
Methods included from TransactionSupport
after_commit, after_rollback, #save, #save!
Methods included from Validations
#save, #save!, #valid?, #validate, #validate!
Methods included from Persistence
#save, #save!, #update, #update!
Methods included from Callbacks
after_create, after_save, after_update, around_create, around_save, around_update, before_create, before_save, before_update
Constructor Details
#initialize(attributes = {}) ⇒ Model
Returns a new instance of Model.
92 93 94 |
# File 'lib/active_record_compose/model.rb', line 92 def initialize(attributes = {}) super end |
Instance Method Details
#id ⇒ Object
Returns the ID value. This value is used when passing it to the :model option of form_with, etc.
Normally it returns nil, but it can be overridden to delegate to the containing model.
117 |
# File 'lib/active_record_compose/model.rb', line 117 def id = nil |
#models ⇒ ActiveRecordCompose::ComposedCollection (private)
Returns a collection of model elements to encapsulate.
130 |
# File 'lib/active_record_compose/model.rb', line 130 def models = @__models ||= ActiveRecordCompose::ComposedCollection.new(self) |