File: yaml.rb

package info (click to toggle)
ruby-asetus 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144 kB
  • sloc: ruby: 237; makefile: 2
file content (25 lines) | stat: -rw-r--r-- 402 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class Asetus
  def to_yaml(config)
    Adapter::YAML.to config._asetus_to_hash
  end

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

  class Adapter
    class YAML
      class << self
        def to(hash)
          require 'yaml'
          ::YAML.dump hash
        end

        def from(yaml)
          require 'yaml'
          ::YAML.unsafe_load yaml
        end
      end
    end
  end
end