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

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cads_new_recordObject

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

#midObject

Returns the value of attribute mid.



51
52
53
# File 'lib/ca/data_store/model.rb', line 51

def mid
  @mid
end

#ts_createdObject

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_updatedObject

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

.init(*args, &block) ⇒ Object



43
44
45
# File 'lib/ca/data_store/model.rb', line 43

def Model.init(*args, &block)
  Provider.instance.provider.handle(:init, *args, &block)
end

.reset(*args, &block) ⇒ Object



47
48
49
# File 'lib/ca/data_store/model.rb', line 47

def Model.reset(*args, &block)
  Provider.instance.provider.handle(:reset, *args, &block)
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

Returns:

  • (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