Sha256: 0a6b550021b901bef14be6d75dff9cea8135a87e1a673dd4d2e5dd991866c237

Contents?: true

Size: 606 Bytes

Versions: 12

Compression:

Stored size: 606 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 running_from!

    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

12 entries across 12 versions & 1 rubygems

Version Path
puma-5.0.4-java lib/puma/state_file.rb
puma-5.0.4 lib/puma/state_file.rb
puma-5.0.3-java lib/puma/state_file.rb
puma-5.0.3 lib/puma/state_file.rb
puma-5.0.2-java lib/puma/state_file.rb
puma-5.0.2 lib/puma/state_file.rb
puma-5.0.1-java lib/puma/state_file.rb
puma-5.0.1 lib/puma/state_file.rb
puma-5.0.0-java lib/puma/state_file.rb
puma-5.0.0 lib/puma/state_file.rb
puma-5.0.0.beta2-java lib/puma/state_file.rb
puma-5.0.0.beta2 lib/puma/state_file.rb