Sha256: feb8a786157943e3d8ee070704185b270fd77ed43506b416a37331c3e1fa55e9

Contents?: true

Size: 427 Bytes

Versions: 1

Compression:

Stored size: 427 Bytes

Contents

require 'singleton'
require 'json'

module JsonReducer
  class Schemas
    include Singleton

    attr_accessor :base_path

    def initialize
      @schemas = {}
      @base_path = nil
    end

    def get(key)
      @schemas[key]
    end

    def set(key, schema, file)
      value = file ? File.read("#{@base_path}/#{schema}") : schema
      @schemas[key] = value.is_a?(String) ? JSON.parse(value) : value
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
json_reducer-1.1.0 lib/json_reducer/schemas.rb