File: json.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-- 406 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_json(config)
    Adapter::JSON.to config._asetus_to_hash
  end

  def from_json(json)
    Adapter::JSON.from json
  end

  class Adapter
    class JSON
      class << self
        def to(hash)
          require 'json'
          ::JSON.pretty_generate hash
        end

        def from(json)
          require 'json'
          ::JSON.load json
        end
      end
    end
  end
end