Module: Ca::DataStore::Model
- Includes:
- TR::CondUtils, TeLogger::TeLogHelper
- Defined in:
- lib/ca/data_store/model.rb
Overview
All method from this model is prefixed with cads_ to separate the call with included/extended class. Notably case in mind is ActiveRecord
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#cads_new_record ⇒ Object
Returns the value of attribute cads_new_record.
-
#mid ⇒ Object
Returns the value of attribute mid.
-
#ts_created ⇒ Object
Returns the value of attribute ts_created.
-
#ts_updated ⇒ Object
Returns the value of attribute ts_updated.
Class Method Summary collapse
-
.included(klass) ⇒ Object
ClassMethods.
- .init(*args, &block) ⇒ Object
- .reset(*args, &block) ⇒ Object
Instance Method Summary collapse
- #cads_delete(*args, &block) ⇒ Object
- #cads_save(*args, &block) ⇒ Object
- #is_cads_new_record?(*args, &block) ⇒ Boolean
Instance Attribute Details
#cads_new_record ⇒ Object
Returns the value of attribute cads_new_record.
51 52 53 |
# File 'lib/ca/data_store/model.rb', line 51 def cads_new_record @cads_new_record end |
#mid ⇒ Object
Returns the value of attribute mid.
51 52 53 |
# File 'lib/ca/data_store/model.rb', line 51 def mid @mid end |
#ts_created ⇒ Object
Returns the value of attribute ts_created.
51 52 53 |
# File 'lib/ca/data_store/model.rb', line 51 def ts_created @ts_created end |
#ts_updated ⇒ Object
Returns the value of attribute ts_updated.
51 52 53 |
# File 'lib/ca/data_store/model.rb', line 51 def ts_updated @ts_updated end |
Class Method Details
.included(klass) ⇒ Object
ClassMethods
39 40 41 |
# File 'lib/ca/data_store/model.rb', line 39 def self.included(klass) klass.extend(ClassMethods) end |
Instance Method Details
#cads_delete(*args, &block) ⇒ Object
60 61 62 |
# File 'lib/ca/data_store/model.rb', line 60 def cads_delete(*args, &block) Provider.instance.provider.handle(:delete, self, *args, &block) end |
#cads_save(*args, &block) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/ca/data_store/model.rb', line 53 def cads_save(*args, &block) if is_cads_new_record? and is_empty?(@mid) @mid = SecureRandom.hex(16) end Provider.instance.provider.handle(:save, self, *args, &block) end |
#is_cads_new_record?(*args, &block) ⇒ Boolean
64 65 66 67 68 |
# File 'lib/ca/data_store/model.rb', line 64 def is_cads_new_record?(*args, &block) @cads_new_record = Provider.instance.provider.handle(:is_new_record?, self, *args, &block) @cads_new_record = true if is_empty?(@cads_new_record) or not is_bool?(@cads_new_record) @cads_new_record end |