Sha256: 2fed31fa9ab811e30ee14a93a3b95a57b7c002660e8263a7f15a2f6139d6383b

Contents?: true

Size: 528 Bytes

Versions: 3

Compression:

Stored size: 528 Bytes

Contents

# frozen_string_literal: true

class Strada
  def to_yaml(config)
    Adapter::YAML.to config._config_to_hash
  end

  def from_yaml(yaml)
    Adapter::YAML.from yaml
  end

  class Adapter
    class YAML
      # 定义类方法
      class << self
        require "yaml"

        # 将 RUBY(HASH) 数据结构转换为 YAML
        def to(hash)
          ::YAML.dump hash
        end
        # 将 YAML 转换为 RUBY(HASH) 数据结构
        def from(yaml)
          ::YAML.load yaml
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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