module SDL
Constants
- SCALAR_TYPES
- TYPES
- VERSION
Public Class Methods
define(&block)
click to toggle source
Defines a new schema. The block will be evaluated in the context of a {Schema} @return [Schema]
@example
SDL.define do model :user do attribute :name, :string end end
# File lib/sdl.rb, line 28 def self.define(&block) Schema.new(&block) end
load_file(file)
click to toggle source
Loads a schema from a file. The contents of the file will be evaluated in the context of a {Schema} @return [Schema]
@example
SDL.load_file("schema.rb")
# File lib/sdl.rb, line 38 def self.load_file(file) schema = Schema.new schema.instance_eval(File.read(file), file) schema end
parse(name, fields)
click to toggle source
Constructs a model from command-line arguments @raise [ParseError] @return [Model] @see Parser
@example
SDL.parse("user", ["name", "email:required:unique"])
# File lib/sdl.rb, line 51 def self.parse(name, fields) parser = Parser.new fields = fields.map { |field| parser.parse(field) } Model.new(name, fields: fields) end