Class: Expressir::Express::Builders::TypeDeclBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/expressir/express/builders/type_decl_builder.rb

Overview

Builds type_decl nodes.

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
# File 'lib/expressir/express/builders/type_decl_builder.rb', line 8

def call(ast_data)
  id = Builder.build_optional(ast_data[:type_id])
  underlying_type = Builder.build_optional(ast_data[:underlying_type])
  where_rules = if ast_data[:where_clause]
                  Builder.build({ where_clause: ast_data[:where_clause] })
                else
                  []
                end

  Expressir::Model::Declarations::Type.new(
    id: id,
    underlying_type: underlying_type,
    where_rules: [where_rules].flatten,
  )
end