Class: Super::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/super/schema.rb

Overview

The Schema is a general purpose container for describing the “schema” for various purposes. It primarily exists to provide a cohesive user-facing API for defining schemas.

The various “schema types” are likely of more interest

Defined Under Namespace

Classes: Fields

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema_type) ⇒ Schema

Returns a new instance of Schema.

Parameters:



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/super/schema.rb', line 9

def initialize(schema_type)
  @schema_type = schema_type
  @fields = Fields.new

  if @schema_type.respond_to?(:setup)
    @schema_type.setup(fields: @fields)
  end

  if block_given?
    yield(@fields, @schema_type)
  end
end

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



22
23
24
# File 'lib/super/schema.rb', line 22

def fields
  @fields
end

Instance Method Details

#field_keysObject



24
25
26
# File 'lib/super/schema.rb', line 24

def field_keys
  fields.keys
end