module ArtirixDataModels
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)
Constants
- DisabledCache
- DisabledLogger
internal Classes
- VERSION
Public Class Methods
cache()
click to toggle source
CACHE
# File lib/artirix_data_models.rb, line 102 def self.cache cache_loader.call end
cache=(cache)
click to toggle source
# File lib/artirix_data_models.rb, line 124 def self.cache=(cache) @cache_loader = -> { cache } end
cache_loader()
click to toggle source
# File lib/artirix_data_models.rb, line 116 def self.cache_loader @cache_loader ||= default_cache_loader end
cache_loader=(loader=nil, &block)
click to toggle source
# 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()
click to toggle source
CONFIGURATION
# File lib/artirix_data_models.rb, line 142 def self.configuration configuration_loader.call end
configuration_loader()
click to toggle source
# File lib/artirix_data_models.rb, line 156 def self.configuration_loader @configuration_loader ||= default_configuration_loader end
configuration_loader=(loader=nil, &block)
click to toggle source
# 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()
click to toggle source
# File lib/artirix_data_models.rb, line 120 def self.default_cache_loader lambda { defined?(Rails) ? Rails.cache : disabled_cache } end
default_configuration_loader()
click to toggle source
# 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()
click to toggle source
# File lib/artirix_data_models.rb, line 84 def self.default_logger_loader lambda { defined?(Rails) ? Rails.logger : disabled_logger } end
disable_cache()
click to toggle source
# File lib/artirix_data_models.rb, line 128 def self.disable_cache @cache_loader = -> { disabled_cache } end
disable_logger()
click to toggle source
# File lib/artirix_data_models.rb, line 92 def self.disable_logger @logger_loader = -> { disabled_logger } end
disabled_cache()
click to toggle source
# File lib/artirix_data_models.rb, line 132 def self.disabled_cache @disabled_cache ||= DisabledCache.new end
disabled_logger()
click to toggle source
# File lib/artirix_data_models.rb, line 96 def self.disabled_logger @disabled_logger ||= DisabledLogger.new end
logger()
click to toggle source
LOGGER
# File lib/artirix_data_models.rb, line 66 def self.logger logger_loader.call end
logger=(logger)
click to toggle source
# File lib/artirix_data_models.rb, line 88 def self.logger=(logger) @logger_loader = -> { logger } end
logger_loader()
click to toggle source
# File lib/artirix_data_models.rb, line 80 def self.logger_loader @logger_loader ||= default_logger_loader end
logger_loader=(loader=nil, &block)
click to toggle source
# 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)
click to toggle source
# File lib/artirix_data_models.rb, line 136 def self.use_cache_service(artirix_cache_service) CacheService.use_cache_service artirix_cache_service end