Module: ArtirixDataModels
- Defined in:
- lib/artirix_data_models/model.rb,
lib/artirix_data_models.rb,
lib/artirix_data_models/dao.rb,
lib/artirix_data_models/version.rb,
lib/artirix_data_models/active_null.rb,
lib/artirix_data_models/aggregation.rb,
lib/artirix_data_models/inspectable.rb,
lib/artirix_data_models/es_collection.rb,
lib/artirix_data_models/aggregation_builder.rb,
lib/artirix_data_models/aggregations_factory.rb,
lib/artirix_data_models/raw_aggregation_data_normaliser.rb,
lib/artirix_data_models/dao_concerns/with_response_adaptors.rb
Overview
Responsibilities
-
ActiveModel compliant (to_param, valid?, save…)
-
Attributes (on initialise, getters and private setters)
-
Automatic timestamp attribute attributes definition (_timestamp)
-
Definition of Primary Key
-
Cache key (calculation of cache key based on minimum information)
-
Partial mode (reload, automatic reload when accessing an unavailable attribute)
6.1 partial mode - Reload with new data hash
6.2 partial mode - Check if in partial mode or in full mode
6.3 partial mode - reload using DAO
-
Rails Model Param based on Primary Key (for URLs and such)
Defined Under Namespace
Modules: ActiveNull, CacheService, DAO, DAOConcerns, GatewayResponseAdaptors, Inspectable, Model, WithDAORegistry
Classes: Aggregation, AggregationBuilder, AggregationsFactory, BasicModelDAO, CachedActionAdaptor, CommonAggregation, ConfigurationNeededError, DAORegistry, DataGateway, EsCollection, FakeResponseFactory, IllegalActionError, MetricAggregation, ModelFieldsDAO, RawAggregationDataNormaliser
Constant Summary
collapse
- DisabledLogger =
Naught.build do |config|
config.black_hole
end
- DisabledCache =
Naught.build do |config|
config.black_hole
def enabled?
false
end
def exist?(*)
false
end
def write(cache_key, value, *_)
value
end
end
- VERSION =
'0.30.0'
Class Method Summary
collapse
Class Method Details
.cache ⇒ Object
102
103
104
|
# File 'lib/artirix_data_models.rb', line 102
def self.cache
cache_loader.call
end
|
.cache=(cache) ⇒ Object
124
125
126
|
# File 'lib/artirix_data_models.rb', line 124
def self.cache=(cache)
@cache_loader = -> { cache }
end
|
.cache_loader ⇒ Object
116
117
118
|
# File 'lib/artirix_data_models.rb', line 116
def self.cache_loader
@cache_loader ||= default_cache_loader
end
|
.cache_loader=(loader = nil, &block) ⇒ Object
106
107
108
109
110
111
112
113
114
|
# File 'lib/artirix_data_models.rb', line 106
def self.cache_loader=(loader=nil, &block)
if block_given?
@cache_loader = block
elsif loader.present? && loader.respond_to?(:call)
@cache_loader = loader
else
raise 'no block or callable object given as a loader'
end
end
|
.configuration ⇒ Object
142
143
144
|
# File 'lib/artirix_data_models.rb', line 142
def self.configuration
configuration_loader.call
end
|
.configuration_loader ⇒ Object
156
157
158
|
# File 'lib/artirix_data_models.rb', line 156
def self.configuration_loader
@configuration_loader ||= default_configuration_loader
end
|
.configuration_loader=(loader = nil, &block) ⇒ Object
146
147
148
149
150
151
152
153
154
|
# File 'lib/artirix_data_models.rb', line 146
def self.configuration_loader=(loader=nil, &block)
if block_given?
@configuration_loader = block
elsif loader.present? && loader.respond_to?(:call)
@configuration_loader = loader
else
raise 'no block or callable object given as a loader'
end
end
|
.default_cache_loader ⇒ Object
120
121
122
|
# File 'lib/artirix_data_models.rb', line 120
def self.default_cache_loader
lambda { defined?(Rails) ? Rails.cache : disabled_cache }
end
|
.default_configuration_loader ⇒ Object
160
161
162
163
164
165
166
167
168
169
170
|
# File 'lib/artirix_data_models.rb', line 160
def self.default_configuration_loader
lambda do
if defined?(Rails) && Rails.configuration.try(:x) && Rails.configuration.x.artirix_data_models.present?
Rails.configuration.x.artirix_data_models
elsif defined?(SimpleConfig)
SimpleConfig.for(:site)
else
raise ConfigurationNeededError, 'Rails.configuration.x.artirix_data_models not available, and SimpleConfig.for(:site) not available'
end
end
end
|
.default_logger_loader ⇒ Object
84
85
86
|
# File 'lib/artirix_data_models.rb', line 84
def self.default_logger_loader
lambda { defined?(Rails) ? Rails.logger : disabled_logger }
end
|
.disable_cache ⇒ Object
128
129
130
|
# File 'lib/artirix_data_models.rb', line 128
def self.disable_cache
@cache_loader = -> { disabled_cache }
end
|
.disable_logger ⇒ Object
92
93
94
|
# File 'lib/artirix_data_models.rb', line 92
def self.disable_logger
@logger_loader = -> { disabled_logger }
end
|
.disabled_cache ⇒ Object
132
133
134
|
# File 'lib/artirix_data_models.rb', line 132
def self.disabled_cache
@disabled_cache ||= DisabledCache.new
end
|
.disabled_logger ⇒ Object
96
97
98
|
# File 'lib/artirix_data_models.rb', line 96
def self.disabled_logger
@disabled_logger ||= DisabledLogger.new
end
|
.logger ⇒ Object
66
67
68
|
# File 'lib/artirix_data_models.rb', line 66
def self.logger
logger_loader.call
end
|
.logger=(logger) ⇒ Object
88
89
90
|
# File 'lib/artirix_data_models.rb', line 88
def self.logger=(logger)
@logger_loader = -> { logger }
end
|
.logger_loader ⇒ Object
80
81
82
|
# File 'lib/artirix_data_models.rb', line 80
def self.logger_loader
@logger_loader ||= default_logger_loader
end
|
.logger_loader=(loader = nil, &block) ⇒ Object
70
71
72
73
74
75
76
77
78
|
# File 'lib/artirix_data_models.rb', line 70
def self.logger_loader=(loader=nil, &block)
if block_given?
@logger_loader = block
elsif loader.present? && loader.respond_to?(:call)
@logger_loader = loader
else
raise 'no block or callable object given as a loader'
end
end
|
.use_cache_service(artirix_cache_service) ⇒ Object
136
137
138
|
# File 'lib/artirix_data_models.rb', line 136
def self.use_cache_service(artirix_cache_service)
CacheService.use_cache_service artirix_cache_service
end
|