Module: Types
- Includes:
- Dry::Core::Constants
- Defined in:
- lib/appfuel/types.rb
Class Method Summary collapse
- .[](key) ⇒ Class
-
.container ⇒ Object
Container used to store validation types and domain entities.
- .key?(key) ⇒ Class
-
.register(key, klass) ⇒ Object
Register a dependency that can be used for injection.
- .register_domain(klass, opts = {}) ⇒ Object
Class Method Details
.[](key) ⇒ Class
16 17 18 |
# File 'lib/appfuel/types.rb', line 16 def [](key) Dry::Types[key] end |
.container ⇒ Object
Container used to store validation types and domain entities
29 30 31 |
# File 'lib/appfuel/types.rb', line 29 def container Dry::Types.container end |
.key?(key) ⇒ Class
22 23 24 |
# File 'lib/appfuel/types.rb', line 22 def key?(key) Dry::Types.container.key?(key) end |
.register(key, klass) ⇒ Object
Register a dependency that can be used for injection
38 39 40 |
# File 'lib/appfuel/types.rb', line 38 def register(key, klass) container.register(key, klass) end |
.register_domain(klass, opts = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/appfuel/types.rb', line 42 def register_domain(klass, opts = {}) unless klass.respond_to?(:domain_name) fail "Domain must be a Appfuel::Entity or respond to :domain_name" end name = opts.key?(:as) ? opt[:as] : klass.domain_name return if key?(name) && self[name] == klass register(name, klass) end |