Sha256: 496f1cc6a98423f1c6c34038158ef635db86600af2aec0023562b02e208fe3b4
Contents?: true
Size: 972 Bytes
Versions: 33
Compression:
Stored size: 972 Bytes
Contents
# coding: utf-8 # frozen_string_literal: true require 'thread' module Stealth class Configuration < Hash def initialize(hash) hash.each do |k, v| self[k] = store(v) end self end def method_missing(method, *args) key = create_config_attribute(method) if setter?(method) self[key] = args.first else super(method, args) && return unless key?(key) self[key] end end private def store(value) if value.is_a?(Hash) Stealth::Configuration.new(value) else value end end def setter?(method) method.slice(-1, 1) == "=" end def create_config_attribute(method) key = basic_config_attribute_from_method(method) key?(key.to_s) ? key.to_s : key end def basic_config_attribute_from_method(method) setter?(method) ? method.to_s.chop : method end end end
Version data entries
33 entries across 33 versions & 1 rubygems