Module: Fray::Data

Defined in:
lib/fray/data/error_set.rb,
lib/fray/data/query.rb,
lib/fray/data/filter.rb,
lib/fray/data/dataset.rb,
lib/fray/data/response.rb,
lib/fray/data.rb

Overview

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

Defined Under Namespace

Classes: Base, Dataset, ErrorSet, Filter, Query, Response

Class Method Summary collapse

Class Method Details

.define_schema_class(name, schema) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# 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