module ArtirixDataModels::WithDAORegistry
Constants
- DEFAULT_DAO_REGISTRY_LOADER
Attributes
dao_registry_loader[W]
Public Class Methods
loader_or_registry_or_default(dao_registry: nil, dao_registry_loader: nil)
click to toggle source
# File lib/artirix_data_models/with_dao_registry.rb, line 4 def self.loader_or_registry_or_default(dao_registry: nil, dao_registry_loader: nil) raise ArgumentError, 'loader has to respond to :call' if dao_registry_loader.present? && !dao_registry_loader.respond_to?(:call) if dao_registry_loader.respond_to? :call dao_registry_loader.call elsif dao_registry dao_registry else DEFAULT_DAO_REGISTRY_LOADER.call end end
Public Instance Methods
dao_registry()
click to toggle source
set_xxx* methods can be chained (return self) xxx= methods return the value set
# File lib/artirix_data_models/with_dao_registry.rb, line 19 def dao_registry dao_registry_loader.call end
dao_registry=(dao_registry)
click to toggle source
# File lib/artirix_data_models/with_dao_registry.rb, line 34 def dao_registry=(dao_registry) if dao_registry set_dao_registry_loader ->() { dao_registry } else set_default_dao_registry_loader end dao_registry end
dao_registry_loader()
click to toggle source
# File lib/artirix_data_models/with_dao_registry.rb, line 23 def dao_registry_loader @dao_registry_loader || DEFAULT_DAO_REGISTRY_LOADER end
default_dao_registry()
click to toggle source
# File lib/artirix_data_models/with_dao_registry.rb, line 49 def default_dao_registry DEFAULT_DAO_REGISTRY_LOADER.call end
set_dao_registry(dao_registry)
click to toggle source
# File lib/artirix_data_models/with_dao_registry.rb, line 44 def set_dao_registry(dao_registry) self.dao_registry = dao_registry self end
set_dao_registry_and_loader(dao_registry_loader, dao_registry)
click to toggle source
will use the loader if present, if not it will use the registry, if not present it will do nothing.
# File lib/artirix_data_models/with_dao_registry.rb, line 61 def set_dao_registry_and_loader(dao_registry_loader, dao_registry) raise ArgumentError, 'loader has to respond to :call' if dao_registry_loader.present? && !dao_registry_loader.respond_to?(:call) if dao_registry_loader.respond_to? :call set_dao_registry_loader dao_registry_loader elsif dao_registry set_dao_registry dao_registry end self end
set_dao_registry_loader(dao_registry_loader)
click to toggle source
# File lib/artirix_data_models/with_dao_registry.rb, line 29 def set_dao_registry_loader(dao_registry_loader) self.dao_registry_loader = dao_registry_loader self end
set_default_dao_registry_loader()
click to toggle source
# File lib/artirix_data_models/with_dao_registry.rb, line 53 def set_default_dao_registry_loader @dao_registry_loader = nil self end
Also aliased as: set_default_dao_registry