Class: Expressir::Express::Builders::InverseAttrTypeBuilder

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

Overview

Builds inverse_attr_type 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
23
24
25
26
# File 'lib/expressir/express/builders/inverse_attr_type_builder.rb', line 8

def call(ast_data)
  bound_spec = ast_data[:bound_spec] || {}
  bound1 = Builder.build_optional(bound_spec[:bound1])
  bound2 = Builder.build_optional(bound_spec[:bound2])
  base_type_data = ast_data[:entity_ref]
  base_type = if base_type_data.is_a?(Hash)
                Builder.build({ entity_ref: base_type_data })
              end

  if ast_data[:t_set]
    Expressir::Model::DataTypes::Set.new(bound1: bound1,
                                         bound2: bound2, base_type: base_type)
  elsif ast_data[:t_bag]
    Expressir::Model::DataTypes::Bag.new(bound1: bound1,
                                         bound2: bound2, base_type: base_type)
  else
    base_type
  end
end