lib/sinclair/config/methods_builder.rb in sinclair-1.6.0 vs lib/sinclair/config/methods_builder.rb in sinclair-1.6.1

- old
+ new

@@ -31,13 +31,11 @@ # @param default [Hash] Configurations that will receive a default value # value when not configured def initialize(klass, *names) super(klass) - @names = names - @defaults = names.find { |arg| arg.is_a?(Hash) } || {} - names.delete(defaults) + @config_hash = Sinclair::InputHash.input_hash(*names) end # Build the methods in config class # # Methods will be attribute readers that, when an attribute @@ -68,45 +66,16 @@ config_hash.keys end private - attr_reader :names, :defaults - # @method names + attr_reader :config_hash + # @method config_hash # @private # @api private # - # List of configuration names + # Configuration hash # - # @return [Array<Symbol,String>] - - # @method defaults - # @private - # @api private - # - # Configurations that will receive a default value - # # @return [Hash] - - # @private - # - # Builds the final config hash - # - # Config hash merges defauls config hashs - # with {#name_as_hash} - # - # @return [Hash] - def config_hash - @config_hash ||= names_as_hash.merge!(defaults) - end - - # @private - # - # Builds a hash with nil values from config names - # - # @return [Hash] - def names_as_hash - Hash[names.map { |*name| name }] - end end end end