lib/dry/system/components/bootable.rb in dry-system-0.20.0 vs lib/dry/system/components/bootable.rb in dry-system-0.21.0
- old
+ new
@@ -45,13 +45,13 @@
#
# @api public
class Bootable
DEFAULT_FINALIZE = proc {}
- # @!attribute [r] identifier
- # @return [Symbol] component's unique identifier
- attr_reader :identifier
+ # @!attribute [r] key
+ # @return [Symbol] component's unique name
+ attr_reader :name
# @!attribute [r] options
# @return [Hash] component's options
attr_reader :options
@@ -64,14 +64,14 @@
attr_reader :namespace
TRIGGER_MAP = Hash.new { |h, k| h[k] = [] }.freeze
# @api private
- def initialize(identifier, options = {}, &block)
+ def initialize(name, options = {}, &block)
@config = nil
@config_block = nil
- @identifier = identifier
+ @name = name
@triggers = {before: TRIGGER_MAP.dup, after: TRIGGER_MAP.dup}
@options = block ? options.merge(block: block) : options
@namespace = options[:namespace]
finalize = options[:finalize] || DEFAULT_FINALIZE
instance_exec(&finalize)
@@ -147,11 +147,11 @@
# @api public
def settings(&block)
if block
@settings_block = block
elsif @settings_block
- @settings = Settings::DSL.new(identifier, &@settings_block).call
+ @settings = Settings::DSL.new(&@settings_block).call
else
@settings
end
end
@@ -209,32 +209,23 @@
# Return a new instance with updated name and options
#
# @return [Dry::Struct]
#
# @api private
- def new(identifier, new_options = EMPTY_HASH)
- self.class.new(identifier, options.merge(new_options))
+ def new(name, new_options = EMPTY_HASH)
+ self.class.new(name, options.merge(new_options))
end
# Return a new instance with updated options
#
# @return [Dry::Struct]
#
# @api private
def with(new_options)
- self.class.new(identifier, options.merge(new_options))
+ self.class.new(name, options.merge(new_options))
end
- # Return true
- #
- # @return [TrueClass]
- #
- # @api private
- def bootable?
- true
- end
-
private
# Return lifecycle object used for this component
#
# @return [Lifecycle]
@@ -254,10 +245,10 @@
case namespace
when String, Symbol
container.namespace(namespace) { |c| return c }
when true
- container.namespace(identifier) { |c| return c }
+ container.namespace(name) { |c| return c }
when nil
container
else
raise <<-STR
+namespace+ boot option must be true, string or symbol #{namespace.inspect} given.