Module: Hexx::Services::DependenciesDSL
- Included in:
- Base
- Defined in:
- lib/hexx-services/dependencies_dsl.rb
Overview
The module provides features to declare dependencies of service objects from other service objects.
Instance Method Summary collapse
-
#depends_on(name, default = nil) ⇒ Symbol
Declare the dependency with a default value.
Instance Method Details
#depends_on(name, default = nil) ⇒ Symbol
Declare the dependency with a default value
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/hexx-services/dependencies_dsl.rb', line 32 def depends_on(name, default = nil) if default.nil? attr_accessor(name) elsif default.kind_of_service_class? define_method(name) { instance_variable_get(:"@#{ name }") || default } attr_writer name else fail TypeError.new "The #{ default.inspect } is not a service" end self end |