Sha256: ee973a7ac39f3d44f53ac09d6fd6ebe53681bd347d65d05aa43d79ebe15beacc

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

# typed: true
# frozen_string_literal: true

require 'sorbet-runtime'

module Frontman
  class Config
    class << self
      extend T::Sig

      sig do
        params(
          key: T.any(String, Symbol), value: T.untyped
        ).returns(T.self_type)
      end
      def set(key, value)
        @@values ||= {}
        @@values[key.to_sym] = value
        self
      end

      sig do
        params(
          key: T.any(String, Symbol), fallback: T.untyped
        ).returns(T.untyped)
      end
      def get(key, fallback: nil)
        @@values ||= {}
        @@values.key?(key.to_sym) ? @@values[key.to_sym] : fallback
      end

      sig { params(key: T.any(String, Symbol)).returns(T.self_type) }
      def delete(key)
        @@values ||= {}
        @@values.delete(key)
        self
      end

      sig { params(key: T.any(String, Symbol)).returns(T::Boolean) }
      def has?(key)
        @@values ||= {}
        @@values.key?(key.to_sym)
      end

      sig { returns(Hash) }
      def all
        @@values ||= {}
        @@values
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
frontman-ssg-0.1.1 lib/frontman/config.rb
frontman-ssg-0.1.0 lib/frontman/config.rb
frontman-ssg-0.0.4 lib/frontman/config.rb
frontman-ssg-0.0.3 lib/frontman/config.rb
frontman-ssg-0.0.2 lib/frontman/config.rb