Sha256: a263c96228fc79a2b4459184a94a344a3979e6d82b10d2512130127ea581d5d3

Contents?: true

Size: 538 Bytes

Versions: 3

Compression:

Stored size: 538 Bytes

Contents

# frozen_string_literal: true

class Strada
  def to_toml(config)
    Adapter::TOML.to config._config_to_hash
  end

  def from_toml(toml)
    Adapter::TOML.from toml
  end

  class Adapter
    class TOML
      # 定义类方法
      class << self
        require "toml"

        # 将 RUBY(HASH) 数据结构转换为 TOML
        def to(hash)
          ::TOML::Generator.new(hash).body
        end
        # 将 TOML 转换为 RUBY 数据结构
        def from(toml)
          ::TOML.load toml
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
strada-0.0.3 lib/strada/adapter/toml.rb
strada-0.0.2 lib/strada/adapter/toml.rb
strada-0.0.1 lib/strada/adapter/toml.rb