lib/praxis-blueprints/config_hash.rb in praxis-blueprints-3.2 vs lib/praxis-blueprints/config_hash.rb in praxis-blueprints-3.3
- old
+ new
@@ -1,40 +1,43 @@
+# frozen_string_literal: true
module Praxis
class ConfigHash < BasicObject
-
attr_reader :hash
- def self.from(hash={},&block)
- self.new(hash,&block)
+ def self.from(hash = {}, &block)
+ new(hash, &block)
end
- def initialize(hash={},&block)
+ def initialize(hash = {}, &block)
@hash = hash
@block = block
end
def to_hash
- self.instance_eval(&@block)
+ instance_eval(&@block)
@hash
end
- def method_missing(name, value, *rest, &block)
+ def respond_to_missing?(_method_name, _include_private = false)
+ true
+ end
+
+ def method_missing(name, value, *rest, &block) # rubocop:disable Style/MethodMissing
if (existing = @hash[name])
if block
existing << [value, block]
else
existing << value
rest.each do |v|
existing << v
end
end
else
- if rest.any?
- @hash[name] = [value] + rest
- else
- @hash[name] = value
- end
+ @hash[name] = if rest.any?
+ [value] + rest
+ else
+ value
+ end
end
end
-
end
end