Class: Dinamo::Model
- Inherits:
-
Object
- Object
- Dinamo::Model
- Extended by:
- Adapter::Glue
- Includes:
- Attributes, Callback, Dirty, Persistence, Validation
- Defined in:
- lib/dinamo/model.rb,
lib/dinamo/model/dirty.rb,
lib/dinamo/model/caster.rb,
lib/dinamo/model/errors.rb,
lib/dinamo/model/callback.rb,
lib/dinamo/model/validator.rb,
lib/dinamo/model/attributes.rb,
lib/dinamo/model/validation.rb,
lib/dinamo/model/persistence.rb,
lib/dinamo/model/validations/presence.rb
Defined Under Namespace
Modules: Attributes, Callback, Dirty, Persistence, Validation Classes: Caster, Errors
Instance Attribute Summary
Attributes included from Attributes
Class Method Summary collapse
- .default_casters(&block) ⇒ Object
- .inherited(klass) ⇒ Object
- .strict(bool) ⇒ Object
- .strict? ⇒ Boolean
- .table_name ⇒ Object
- .table_name=(name) ⇒ Object
Instance Method Summary collapse
-
#initialize(**attributes, &block) ⇒ Model
constructor
A new instance of Model.
Methods included from Adapter::Glue
Methods included from Dirty
#attribute_changed?, #changed, #changed?, #changed_attributes, #changes, #changes_applied, #clear_changes_information, #clear_previous_attributes
Methods included from Persistence
#create_or_update, #create_record, #destroy, #destroyed?, #new_record=, #new_record?, #persisted?, #reload!, #save, #save!, #transaction, #update, #update!, #update_record
Methods included from Attributes
#==, #[], #[]=, #hash_key, #primary_keys, #range_key, #silent_assign, #variable_attributes
Methods included from Validation
Methods included from Callback
#invoke_callbacks, #with_callback
Constructor Details
#initialize(**attributes, &block) ⇒ Model
Returns a new instance of Model.
59 60 61 62 63 |
# File 'lib/dinamo/model.rb', line 59 def initialize(**attributes, &block) with_callback :initialize, **attributes do block.call(self) if block_given? end end |
Class Method Details
.default_casters(&block) ⇒ Object
22 23 24 |
# File 'lib/dinamo/model.rb', line 22 def default_casters(&block) @default_casters ||= block end |
.inherited(klass) ⇒ Object
26 27 28 29 |
# File 'lib/dinamo/model.rb', line 26 def inherited(klass) klass.callbacks.merge!(callbacks) klass.class_eval &default_casters end |
.strict(bool) ⇒ Object
39 40 41 |
# File 'lib/dinamo/model.rb', line 39 def strict(bool) @strict = bool end |
.strict? ⇒ Boolean
43 44 45 |
# File 'lib/dinamo/model.rb', line 43 def strict? @strict.nil? ? true : @strict end |
.table_name ⇒ Object
31 32 33 |
# File 'lib/dinamo/model.rb', line 31 def table_name @table_name ||= self.name.split(/::/).last.underscore.pluralize end |
.table_name=(name) ⇒ Object
35 36 37 |
# File 'lib/dinamo/model.rb', line 35 def table_name=(name) @table_name = name end |