module Fray::Data

This module simply reads the files in data_structures and reifies them as Structs with on-creation validations. The data strcture files use JSON schema for a format: json-schema.org

This module simply reads the files in data_structures and reifies them as Structs with on-creation validations. The data strcture files use JSON schema for a format: json-schema.org

Public Class Methods

define_schema_class(name, schema) click to toggle source
# File lib/fray/data.rb, line 21
def self.define_schema_class(name, schema)
  const_name = name.split('_').map{|chunk| chunk[0].upcase + chunk[1..-1]}.join('')
  klass = Class.new(Base) do
    define_method :__schema do
      schema
    end
  end

  Fray::Data.const_set(const_name.to_sym, klass.freeze)
end