Module: EntityCache::Store::Internal::Build
- Defined in:
- lib/entity_cache/store/internal/build.rb,
lib/entity_cache/store/internal/build/defaults.rb
Defined Under Namespace
Modules: Defaults
Constant Summary collapse
- ScopeError =
Class.new(RuntimeError)
Class Method Summary collapse
- .call(subject, scope: nil) ⇒ Object
- .default_scope_class ⇒ Object
- .logger ⇒ Object
- .scope_class(scope) ⇒ Object
- .scopes ⇒ Object
Class Method Details
.call(subject, scope: nil) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/entity_cache/store/internal/build.rb', line 5 def self.call(subject, scope: nil) scope ||= Defaults.scope cls = scope_class(scope) cls.build(subject) end |
.default_scope_class ⇒ Object
13 14 15 |
# File 'lib/entity_cache/store/internal/build.rb', line 13 def self.default_scope_class scope_class(Defaults.scope) end |
.logger ⇒ Object
40 41 42 |
# File 'lib/entity_cache/store/internal/build.rb', line 40 def self.logger @logger ||= Log.get(self) end |
.scope_class(scope) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/entity_cache/store/internal/build.rb', line 17 def self.scope_class(scope) scopes.fetch(scope) do *scopes, final_scope = self.scopes.keys scope_list = <<~TEXT #{scopes.map(&:inspect) * ', '} or #{final_scope.inspect} TEXT = %{Scope #{scope.inspect} is unknown. It must be one of: #{scope_list}} logger.error() raise ScopeError, end end |