Class: Expressir::Express::Builders::SchemaDeclBuilder
- Inherits:
-
Object
- Object
- Expressir::Express::Builders::SchemaDeclBuilder
- Defined in:
- lib/expressir/express/builders/schema_decl_builder.rb
Overview
Builds schema_decl nodes into Schema objects.
Instance Method Summary collapse
Instance Method Details
#call(ast_data) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/expressir/express/builders/schema_decl_builder.rb', line 8 def call(ast_data) id = Builder.build_optional(ast_data[:schema_id]) version = if ast_data[:schema_version_id] Builder.build({ schema_version_id: ast_data[:schema_version_id] }) end interfaces = [] constants = [] declarations = [] if ast_data[:schema_body] interfaces = Builder.build_children(ast_data[:schema_body][:interface_specification]) constants = build_constants(ast_data[:schema_body][:constant_decl]) body_decls = ast_data[:schema_body][:schema_body_declaration] declarations = Builder.build_children(body_decls) if body_decls end types = declarations.grep(Expressir::Model::Declarations::Type) entities = declarations.grep(Expressir::Model::Declarations::Entity) subtype_constraints = declarations.grep(Expressir::Model::Declarations::SubtypeConstraint) functions = declarations.grep(Expressir::Model::Declarations::Function) rules = declarations.grep(Expressir::Model::Declarations::Rule) procedures = declarations.grep(Expressir::Model::Declarations::Procedure) Expressir::Model::Declarations::Schema.new( id: id, version: version, interfaces: interfaces.compact, constants: [constants].flatten, types: types, entities: entities, subtype_constraints: subtype_constraints, functions: functions, rules: rules, procedures: procedures, ) end |