Sha256: ef04c398b2cf713dd88ccf6d5cb7eaa4662d3c380b05fc11599b21c1ce744713

Contents?: true

Size: 593 Bytes

Versions: 2

Compression:

Stored size: 593 Bytes

Contents

# frozen_string_literal: true

require 'yaml'

module Puma
  class StateFile
    def initialize
      @options = {}
    end

    def save(path, permission = nil)
      File.open(path, "w") do |file|
        file.chmod(permission) if permission
        file.write(YAML.dump(@options))
      end
    end

    def load(path)
      @options = YAML.load File.read(path)
    end

    FIELDS = %w!control_url control_auth_token pid!

    FIELDS.each do |f|
      define_method f do
        @options[f]
      end

      define_method "#{f}=" do |v|
        @options[f] = v
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puma-5.0.0.beta1-java lib/puma/state_file.rb
puma-5.0.0.beta1 lib/puma/state_file.rb