Sha256: 0eeb66b38a3ea6f775f5387c4f688e6a083d20ee419c6e9bea2a38ac16c4c29c
Contents?: true
Size: 846 Bytes
Versions: 1
Compression:
Stored size: 846 Bytes
Contents
# frozen_string_literal: true require "dot_hash" module PUNK class Settings < DotHash::Settings alias_method :key?, :has_key? delegate :inspect, to: :_inspect_hash def method_missing(key, *args, &block) match = /^(.*)([!?])$/.match(key) if match && key?(match[1]) && !key?(key) value = execute(match[1], *args, &block) case match[2] when "?" return value if value.is_a?(TrueClass) || value.is_a?(FalseClass) when "!" raise InternalServerError, "Value is nil: #{key}" if value.nil? return value end end super end def respond_to_missing?(key, *args) match = /^(.*)([!?])$/.match(key) key = match[1] if match && !key?(key) super end private def _inspect_hash to_h.inspect end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
punk-0.4.1 | lib/punk/core/settings.rb |