expressir 2.1.13 → 2.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +7 -82
  3. data/.rubocop_todo.yml +15 -74
  4. data/Gemfile +4 -5
  5. data/expressir.gemspec +3 -1
  6. data/lib/expressir/express/cache.rb +4 -6
  7. data/lib/expressir/express/formatter.rb +92 -63
  8. data/lib/expressir/express/model_visitor.rb +10 -9
  9. data/lib/expressir/express/parser.rb +10 -8
  10. data/lib/expressir/express/resolve_references_model_visitor.rb +0 -3
  11. data/lib/expressir/express/visitor.rb +2 -1
  12. data/lib/expressir/liquid.rb +0 -17
  13. data/lib/expressir/model/cache.rb +9 -8
  14. data/lib/expressir/model/data_types/aggregate.rb +6 -11
  15. data/lib/expressir/model/data_types/array.rb +14 -20
  16. data/lib/expressir/model/data_types/bag.rb +10 -14
  17. data/lib/expressir/model/data_types/binary.rb +8 -11
  18. data/lib/expressir/model/data_types/boolean.rb +6 -1
  19. data/lib/expressir/model/data_types/enumeration.rb +10 -14
  20. data/lib/expressir/model/data_types/enumeration_item.rb +3 -5
  21. data/lib/expressir/model/data_types/generic.rb +4 -6
  22. data/lib/expressir/model/data_types/generic_entity.rb +4 -6
  23. data/lib/expressir/model/data_types/integer.rb +6 -1
  24. data/lib/expressir/model/data_types/list.rb +12 -17
  25. data/lib/expressir/model/data_types/logical.rb +6 -1
  26. data/lib/expressir/model/data_types/number.rb +6 -1
  27. data/lib/expressir/model/data_types/real.rb +6 -8
  28. data/lib/expressir/model/data_types/select.rb +12 -17
  29. data/lib/expressir/model/data_types/set.rb +10 -14
  30. data/lib/expressir/model/data_types/string.rb +8 -11
  31. data/lib/expressir/model/declarations/attribute.rb +17 -26
  32. data/lib/expressir/model/declarations/constant.rb +8 -14
  33. data/lib/expressir/model/declarations/entity.rb +18 -29
  34. data/lib/expressir/model/declarations/function.rb +25 -39
  35. data/lib/expressir/model/declarations/interface.rb +12 -16
  36. data/lib/expressir/model/declarations/interface_item.rb +7 -11
  37. data/lib/expressir/model/declarations/interfaced_item.rb +11 -18
  38. data/lib/expressir/model/declarations/parameter.rb +8 -14
  39. data/lib/expressir/model/declarations/procedure.rb +23 -36
  40. data/lib/expressir/model/declarations/remark_item.rb +8 -11
  41. data/lib/expressir/model/declarations/rule.rb +27 -42
  42. data/lib/expressir/model/declarations/schema.rb +59 -58
  43. data/lib/expressir/model/declarations/schema_version.rb +7 -10
  44. data/lib/expressir/model/declarations/schema_version_item.rb +7 -10
  45. data/lib/expressir/model/declarations/subtype_constraint.rb +12 -20
  46. data/lib/expressir/model/declarations/type.rb +10 -17
  47. data/lib/expressir/model/declarations/unique_rule.rb +6 -11
  48. data/lib/expressir/model/declarations/variable.rb +8 -14
  49. data/lib/expressir/model/declarations/where_rule.rb +6 -11
  50. data/lib/expressir/model/expressions/aggregate_initializer.rb +6 -8
  51. data/lib/expressir/model/expressions/aggregate_initializer_item.rb +8 -11
  52. data/lib/expressir/model/expressions/binary_expression.rb +40 -42
  53. data/lib/expressir/model/expressions/entity_constructor.rb +8 -11
  54. data/lib/expressir/model/expressions/function_call.rb +8 -11
  55. data/lib/expressir/model/expressions/interval.rb +16 -22
  56. data/lib/expressir/model/expressions/query_expression.rb +8 -14
  57. data/lib/expressir/model/expressions/unary_expression.rb +11 -14
  58. data/lib/expressir/model/identifier.rb +8 -25
  59. data/lib/expressir/model/literals/binary.rb +6 -8
  60. data/lib/expressir/model/literals/integer.rb +6 -8
  61. data/lib/expressir/model/literals/logical.rb +9 -11
  62. data/lib/expressir/model/literals/real.rb +6 -8
  63. data/lib/expressir/model/literals/string.rb +8 -11
  64. data/lib/expressir/model/model_element.rb +164 -131
  65. data/lib/expressir/model/references/attribute_reference.rb +8 -11
  66. data/lib/expressir/model/references/group_reference.rb +8 -11
  67. data/lib/expressir/model/references/index_reference.rb +10 -14
  68. data/lib/expressir/model/references/simple_reference.rb +10 -13
  69. data/lib/expressir/model/repository.rb +5 -7
  70. data/lib/expressir/model/statements/alias.rb +8 -14
  71. data/lib/expressir/model/statements/assignment.rb +8 -11
  72. data/lib/expressir/model/statements/case.rb +10 -14
  73. data/lib/expressir/model/statements/case_action.rb +7 -10
  74. data/lib/expressir/model/statements/compound.rb +6 -8
  75. data/lib/expressir/model/statements/escape.rb +6 -1
  76. data/lib/expressir/model/statements/if.rb +10 -14
  77. data/lib/expressir/model/statements/null.rb +6 -1
  78. data/lib/expressir/model/statements/procedure_call.rb +8 -11
  79. data/lib/expressir/model/statements/repeat.rb +16 -26
  80. data/lib/expressir/model/statements/return.rb +6 -8
  81. data/lib/expressir/model/statements/skip.rb +6 -1
  82. data/lib/expressir/model/supertype_expressions/binary_supertype_expression.rb +12 -16
  83. data/lib/expressir/model/supertype_expressions/oneof_supertype_expression.rb +6 -8
  84. data/lib/expressir/model.rb +1 -8
  85. data/lib/expressir/version.rb +1 -1
  86. data/lib/expressir.rb +7 -3
  87. metadata +32 -89
  88. data/lib/expressir/liquid/cache_drop.rb +0 -20
  89. data/lib/expressir/liquid/data_type_drop.rb +0 -8
  90. data/lib/expressir/liquid/data_types/aggregate_drop.rb +0 -21
  91. data/lib/expressir/liquid/data_types/array_drop.rb +0 -34
  92. data/lib/expressir/liquid/data_types/bag_drop.rb +0 -26
  93. data/lib/expressir/liquid/data_types/binary_drop.rb +0 -22
  94. data/lib/expressir/liquid/data_types/boolean_drop.rb +0 -10
  95. data/lib/expressir/liquid/data_types/enumeration_drop.rb +0 -30
  96. data/lib/expressir/liquid/data_types/enumeration_item_drop.rb +0 -17
  97. data/lib/expressir/liquid/data_types/generic_drop.rb +0 -17
  98. data/lib/expressir/liquid/data_types/generic_entity_drop.rb +0 -17
  99. data/lib/expressir/liquid/data_types/integer_drop.rb +0 -10
  100. data/lib/expressir/liquid/data_types/list_drop.rb +0 -30
  101. data/lib/expressir/liquid/data_types/logical_drop.rb +0 -10
  102. data/lib/expressir/liquid/data_types/number_drop.rb +0 -10
  103. data/lib/expressir/liquid/data_types/real_drop.rb +0 -18
  104. data/lib/expressir/liquid/data_types/select_drop.rb +0 -34
  105. data/lib/expressir/liquid/data_types/set_drop.rb +0 -26
  106. data/lib/expressir/liquid/data_types/string_drop.rb +0 -22
  107. data/lib/expressir/liquid/declaration_drop.rb +0 -8
  108. data/lib/expressir/liquid/declarations/attribute_drop.rb +0 -37
  109. data/lib/expressir/liquid/declarations/constant_drop.rb +0 -25
  110. data/lib/expressir/liquid/declarations/entity_drop.rb +0 -65
  111. data/lib/expressir/liquid/declarations/function_drop.rb +0 -93
  112. data/lib/expressir/liquid/declarations/interface_drop.rb +0 -30
  113. data/lib/expressir/liquid/declarations/interface_item_drop.rb +0 -22
  114. data/lib/expressir/liquid/declarations/interfaced_item_drop.rb +0 -34
  115. data/lib/expressir/liquid/declarations/parameter_drop.rb +0 -25
  116. data/lib/expressir/liquid/declarations/procedure_drop.rb +0 -89
  117. data/lib/expressir/liquid/declarations/remark_item_drop.rb +0 -22
  118. data/lib/expressir/liquid/declarations/rule_drop.rb +0 -105
  119. data/lib/expressir/liquid/declarations/schema_drop.rb +0 -131
  120. data/lib/expressir/liquid/declarations/schema_version_drop.rb +0 -26
  121. data/lib/expressir/liquid/declarations/schema_version_item_drop.rb +0 -22
  122. data/lib/expressir/liquid/declarations/subtype_constraint_drop.rb +0 -37
  123. data/lib/expressir/liquid/declarations/type_drop.rb +0 -37
  124. data/lib/expressir/liquid/declarations/unique_rule_drop.rb +0 -21
  125. data/lib/expressir/liquid/declarations/variable_drop.rb +0 -25
  126. data/lib/expressir/liquid/declarations/where_rule_drop.rb +0 -21
  127. data/lib/expressir/liquid/expression_drop.rb +0 -8
  128. data/lib/expressir/liquid/expressions/aggregate_initializer_drop.rb +0 -24
  129. data/lib/expressir/liquid/expressions/aggregate_initializer_item_drop.rb +0 -22
  130. data/lib/expressir/liquid/expressions/binary_expression_drop.rb +0 -26
  131. data/lib/expressir/liquid/expressions/entity_constructor_drop.rb +0 -26
  132. data/lib/expressir/liquid/expressions/function_call_drop.rb +0 -26
  133. data/lib/expressir/liquid/expressions/interval_drop.rb +0 -34
  134. data/lib/expressir/liquid/expressions/query_expression_drop.rb +0 -25
  135. data/lib/expressir/liquid/expressions/unary_expression_drop.rb +0 -22
  136. data/lib/expressir/liquid/identifier_drop.rb +0 -33
  137. data/lib/expressir/liquid/literal_drop.rb +0 -8
  138. data/lib/expressir/liquid/literals/binary_drop.rb +0 -18
  139. data/lib/expressir/liquid/literals/integer_drop.rb +0 -18
  140. data/lib/expressir/liquid/literals/logical_drop.rb +0 -18
  141. data/lib/expressir/liquid/literals/real_drop.rb +0 -18
  142. data/lib/expressir/liquid/literals/string_drop.rb +0 -22
  143. data/lib/expressir/liquid/model_element_drop.rb +0 -33
  144. data/lib/expressir/liquid/reference_drop.rb +0 -8
  145. data/lib/expressir/liquid/references/attribute_reference_drop.rb +0 -22
  146. data/lib/expressir/liquid/references/group_reference_drop.rb +0 -22
  147. data/lib/expressir/liquid/references/index_reference_drop.rb +0 -26
  148. data/lib/expressir/liquid/references/simple_reference_drop.rb +0 -22
  149. data/lib/expressir/liquid/repository_drop.rb +0 -25
  150. data/lib/expressir/liquid/statement_drop.rb +0 -8
  151. data/lib/expressir/liquid/statements/alias_drop.rb +0 -29
  152. data/lib/expressir/liquid/statements/assignment_drop.rb +0 -22
  153. data/lib/expressir/liquid/statements/case_action_drop.rb +0 -26
  154. data/lib/expressir/liquid/statements/case_drop.rb +0 -30
  155. data/lib/expressir/liquid/statements/compound_drop.rb +0 -22
  156. data/lib/expressir/liquid/statements/escape_drop.rb +0 -10
  157. data/lib/expressir/liquid/statements/if_drop.rb +0 -34
  158. data/lib/expressir/liquid/statements/null_drop.rb +0 -10
  159. data/lib/expressir/liquid/statements/procedure_call_drop.rb +0 -26
  160. data/lib/expressir/liquid/statements/repeat_drop.rb +0 -45
  161. data/lib/expressir/liquid/statements/return_drop.rb +0 -18
  162. data/lib/expressir/liquid/statements/skip_drop.rb +0 -10
  163. data/lib/expressir/liquid/supertype_expression_drop.rb +0 -8
  164. data/lib/expressir/liquid/supertype_expressions/binary_supertype_expression_drop.rb +0 -26
  165. data/lib/expressir/liquid/supertype_expressions/oneof_supertype_expression_drop.rb +0 -22
  166. data/lib/expressir/model/data_type.rb +0 -9
  167. data/lib/expressir/model/declaration.rb +0 -9
  168. data/lib/expressir/model/expression.rb +0 -9
  169. data/lib/expressir/model/literal.rb +0 -9
  170. data/lib/expressir/model/reference.rb +0 -9
  171. data/lib/expressir/model/statement.rb +0 -9
  172. data/lib/expressir/model/supertype_expression.rb +0 -9
@@ -3,20 +3,15 @@ module Expressir
3
3
  module DataTypes
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 9.5.3.1 Aggregate data type
6
- class Aggregate < DataType
6
+ class Aggregate < ModelElement
7
7
  include Identifier
8
8
 
9
- model_attr_accessor :base_type, "Type"
9
+ attribute :base_type, ModelElement
10
+ attribute :_class, :string, default: -> { send(:name) }
10
11
 
11
- # @param [Hash] options
12
- # @option (see Identifier#initialize_identifier)
13
- # @option options [Type] :base_type
14
- def initialize(options = {})
15
- initialize_identifier(options)
16
-
17
- @base_type = options[:base_type]
18
-
19
- super
12
+ key_value do
13
+ map "_class", to: :_class, render_default: true
14
+ map "base_type", to: :base_type
20
15
  end
21
16
 
22
17
  # @return [Array<Declaration>]
@@ -3,27 +3,21 @@ module Expressir
3
3
  module DataTypes
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 8.2.1 Array data type
6
- class Array < DataType
7
- model_attr_accessor :bound1, "Expression"
8
- model_attr_accessor :bound2, "Expression"
9
- model_attr_accessor :optional, "::Boolean"
10
- model_attr_accessor :unique, "::Boolean"
11
- model_attr_accessor :base_type, "DataType"
6
+ class Array < ModelElement
7
+ attribute :bound1, ModelElement
8
+ attribute :bound2, ModelElement
9
+ attribute :optional, :boolean
10
+ attribute :unique, :boolean
11
+ attribute :base_type, ModelElement
12
+ attribute :_class, :string, default: -> { send(:name) }
12
13
 
13
- # @param [Hash] options
14
- # @option options [Expression] :bound1
15
- # @option options [Expression] :bound2
16
- # @option options [::Boolean] :optional
17
- # @option options [::Boolean] :unique
18
- # @option options [DataType] :base_type
19
- def initialize(options = {})
20
- @bound1 = options[:bound1]
21
- @bound2 = options[:bound2]
22
- @optional = options[:optional]
23
- @unique = options[:unique]
24
- @base_type = options[:base_type]
25
-
26
- super
14
+ key_value do
15
+ map "_class", to: :_class, render_default: true
16
+ map "bound1", to: :bound1
17
+ map "bound2", to: :bound2
18
+ map "optional", to: :optional
19
+ map "unique", to: :unique
20
+ map "base_type", to: :base_type
27
21
  end
28
22
  end
29
23
  end
@@ -3,21 +3,17 @@ module Expressir
3
3
  module DataTypes
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 8.2.3 Bag data type
6
- class Bag < DataType
7
- model_attr_accessor :bound1, "Expression"
8
- model_attr_accessor :bound2, "Expression"
9
- model_attr_accessor :base_type, "DataType"
6
+ class Bag < ModelElement
7
+ attribute :bound1, ModelElement
8
+ attribute :bound2, ModelElement
9
+ attribute :base_type, ModelElement
10
+ attribute :_class, :string, default: -> { send(:name) }
10
11
 
11
- # @param [Hash] options
12
- # @option options [Expression] :bound1
13
- # @option options [Expression] :bound2
14
- # @option options [DataType] :base_type
15
- def initialize(options = {})
16
- @bound1 = options[:bound1]
17
- @bound2 = options[:bound2]
18
- @base_type = options[:base_type]
19
-
20
- super
12
+ key_value do
13
+ map "_class", to: :_class, render_default: true
14
+ map "bound1", to: :bound1
15
+ map "bound2", to: :bound2
16
+ map "base_type", to: :base_type
21
17
  end
22
18
  end
23
19
  end
@@ -3,18 +3,15 @@ module Expressir
3
3
  module DataTypes
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 8.1.7 Binary data type
6
- class Binary < DataType
7
- model_attr_accessor :width, "Expression"
8
- model_attr_accessor :fixed, "::Boolean"
6
+ class Binary < ModelElement
7
+ attribute :width, ModelElement
8
+ attribute :fixed, :boolean
9
+ attribute :_class, :string, default: -> { send(:name) }
9
10
 
10
- # @param [Hash] options
11
- # @option options [Expression] :width
12
- # @option options [::Boolean] :fixed
13
- def initialize(options = {})
14
- @width = options[:width]
15
- @fixed = options[:fixed]
16
-
17
- super
11
+ key_value do
12
+ map "_class", to: :_class, render_default: true
13
+ map "width", to: :width
14
+ map "fixed", to: :fixed
18
15
  end
19
16
  end
20
17
  end
@@ -3,7 +3,12 @@ module Expressir
3
3
  module DataTypes
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 8.1.5 Boolean data type
6
- class Boolean < DataType
6
+ class Boolean < ModelElement
7
+ attribute :_class, :string, default: -> { send(:name) }
8
+
9
+ key_value do
10
+ map "_class", to: :_class, render_default: true
11
+ end
7
12
  end
8
13
  end
9
14
  end
@@ -3,21 +3,17 @@ module Expressir
3
3
  module DataTypes
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 8.4.1 Enumeration data type
6
- class Enumeration < DataType
7
- model_attr_accessor :extensible, "::Boolean"
8
- model_attr_accessor :based_on, "Reference"
9
- model_attr_accessor :items, "::Array<EnumerationItem>"
6
+ class Enumeration < ModelElement
7
+ attribute :extensible, :boolean
8
+ attribute :based_on, ModelElement
9
+ attribute :items, EnumerationItem, collection: true
10
+ attribute :_class, :string, default: -> { send(:name) }
10
11
 
11
- # @param [Hash] options
12
- # @option options [::Boolean] :extensible
13
- # @option options [Reference] :based_on
14
- # @option options [::Array<EnumerationItem>] :items
15
- def initialize(options = {})
16
- @extensible = options[:extensible]
17
- @based_on = options[:based_on]
18
- @items = options[:items] || []
19
-
20
- super
12
+ key_value do
13
+ map "_class", to: :_class, render_default: true
14
+ map "extensible", to: :extensible
15
+ map "based_on", to: :based_on
16
+ map "items", to: :items
21
17
  end
22
18
  end
23
19
  end
@@ -6,12 +6,10 @@ module Expressir
6
6
  class EnumerationItem < ModelElement
7
7
  include Identifier
8
8
 
9
- # @param [Hash] options
10
- # @option (see Identifier#initialize_identifier)
11
- def initialize(options = {})
12
- initialize_identifier(options)
9
+ attribute :_class, :string, default: -> { send(:name) }
13
10
 
14
- super
11
+ key_value do
12
+ map "_class", to: :_class, render_default: true
15
13
  end
16
14
 
17
15
  # @return [Array<Declaration>]
@@ -3,15 +3,13 @@ module Expressir
3
3
  module DataTypes
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 9.5.3.2 Generic data type
6
- class Generic < DataType
6
+ class Generic < ModelElement
7
7
  include Identifier
8
8
 
9
- # @param [Hash] options
10
- # @option (see Identifier#initialize_identifier)
11
- def initialize(options = {})
12
- initialize_identifier(options)
9
+ attribute :_class, :string, default: -> { send(:name) }
13
10
 
14
- super
11
+ key_value do
12
+ map "_class", to: :_class, render_default: true
15
13
  end
16
14
 
17
15
  # @return [Array<Declaration>]
@@ -3,15 +3,13 @@ module Expressir
3
3
  module DataTypes
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 9.5.3.3 Generic entity data type
6
- class GenericEntity < DataType
6
+ class GenericEntity < ModelElement
7
7
  include Identifier
8
8
 
9
- # @param [Hash] options
10
- # @option (see Identifier#initialize_identifier)
11
- def initialize(options = {})
12
- initialize_identifier(options)
9
+ attribute :_class, :string, default: -> { send(:name) }
13
10
 
14
- super
11
+ key_value do
12
+ map "_class", to: :_class, render_default: true
15
13
  end
16
14
  end
17
15
 
@@ -3,7 +3,12 @@ module Expressir
3
3
  module DataTypes
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 8.1.3 Integer data type
6
- class Integer < DataType
6
+ class Integer < ModelElement
7
+ attribute :_class, :string, default: -> { send(:name) }
8
+
9
+ key_value do
10
+ map "_class", to: :_class, render_default: true
11
+ end
7
12
  end
8
13
  end
9
14
  end
@@ -3,24 +3,19 @@ module Expressir
3
3
  module DataTypes
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 8.2.2 List data type
6
- class List < DataType
7
- model_attr_accessor :bound1, "Expression"
8
- model_attr_accessor :bound2, "Expression"
9
- model_attr_accessor :unique, "::Boolean"
10
- model_attr_accessor :base_type, "DataType"
6
+ class List < ModelElement
7
+ attribute :bound1, ModelElement
8
+ attribute :bound2, ModelElement
9
+ attribute :unique, :boolean
10
+ attribute :base_type, ModelElement
11
+ attribute :_class, :string, default: -> { send(:name) }
11
12
 
12
- # @param [Hash] options
13
- # @option options [Expression] :bound1
14
- # @option options [Expression] :bound2
15
- # @option options [::Boolean] :unique
16
- # @option options [DataType] :base_type
17
- def initialize(options = {})
18
- @bound1 = options[:bound1]
19
- @bound2 = options[:bound2]
20
- @unique = options[:unique]
21
- @base_type = options[:base_type]
22
-
23
- super
13
+ key_value do
14
+ map "_class", to: :_class, render_default: true
15
+ map "bound1", to: :bound1
16
+ map "bound2", to: :bound2
17
+ map "unique", to: :unique
18
+ map "base_type", to: :base_type
24
19
  end
25
20
  end
26
21
  end
@@ -3,7 +3,12 @@ module Expressir
3
3
  module DataTypes
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 8.1.4 Logical data type
6
- class Logical < DataType
6
+ class Logical < ModelElement
7
+ attribute :_class, :string, default: -> { send(:name) }
8
+
9
+ key_value do
10
+ map "_class", to: :_class, render_default: true
11
+ end
7
12
  end
8
13
  end
9
14
  end
@@ -3,7 +3,12 @@ module Expressir
3
3
  module DataTypes
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 8.1.1 Number data type
6
- class Number < DataType
6
+ class Number < ModelElement
7
+ attribute :_class, :string, default: -> { send(:name) }
8
+
9
+ key_value do
10
+ map "_class", to: :_class, render_default: true
11
+ end
7
12
  end
8
13
  end
9
14
  end
@@ -3,15 +3,13 @@ module Expressir
3
3
  module DataTypes
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 8.1.2 Real data type
6
- class Real < DataType
7
- model_attr_accessor :precision, "Expression"
6
+ class Real < ModelElement
7
+ attribute :precision, ModelElement
8
+ attribute :_class, :string, default: -> { send(:name) }
8
9
 
9
- # @param [Hash] options
10
- # @option options [Expression] :precision
11
- def initialize(options = {})
12
- @precision = options[:precision]
13
-
14
- super
10
+ key_value do
11
+ map "_class", to: :_class, render_default: true
12
+ map "precision", to: :precision
15
13
  end
16
14
  end
17
15
  end
@@ -3,24 +3,19 @@ module Expressir
3
3
  module DataTypes
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 8.4.2 Select data type
6
- class Select < DataType
7
- model_attr_accessor :extensible, "::Boolean"
8
- model_attr_accessor :generic_entity, "::Boolean"
9
- model_attr_accessor :based_on, "Reference"
10
- model_attr_accessor :items, "::Array<Reference>"
6
+ class Select < ModelElement
7
+ attribute :extensible, :boolean
8
+ attribute :generic_entity, :boolean
9
+ attribute :based_on, ModelElement
10
+ attribute :items, ModelElement, collection: true
11
+ attribute :_class, :string, default: -> { send(:name) }
11
12
 
12
- # @param [Hash] options
13
- # @option options [::Boolean] :extensible
14
- # @option options [::Boolean] :generic_entity
15
- # @option options [Reference] :based_on
16
- # @option options [::Array<Reference>] :items
17
- def initialize(options = {})
18
- @extensible = options[:extensible]
19
- @generic_entity = options[:generic_entity]
20
- @based_on = options[:based_on]
21
- @items = options[:items] || []
22
-
23
- super
13
+ key_value do
14
+ map "_class", to: :_class, render_default: true
15
+ map "extensible", to: :extensible
16
+ map "generic_entity", to: :generic_entity
17
+ map "based_on", to: :based_on
18
+ map "items", to: :items
24
19
  end
25
20
  end
26
21
  end
@@ -3,21 +3,17 @@ module Expressir
3
3
  module DataTypes
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 8.2.4 Set data type
6
- class Set < DataType
7
- model_attr_accessor :bound1, "Expression"
8
- model_attr_accessor :bound2, "Expression"
9
- model_attr_accessor :base_type, "DataType"
6
+ class Set < ModelElement
7
+ attribute :bound1, ModelElement
8
+ attribute :bound2, ModelElement
9
+ attribute :base_type, ModelElement
10
+ attribute :_class, :string, default: -> { send(:name) }
10
11
 
11
- # @param [Hash] options
12
- # @option options [Expression] :bound1
13
- # @option options [Expression] :bound2
14
- # @option options [DataType] :base_type
15
- def initialize(options = {})
16
- @bound1 = options[:bound1]
17
- @bound2 = options[:bound2]
18
- @base_type = options[:base_type]
19
-
20
- super
12
+ key_value do
13
+ map "_class", to: :_class, render_default: true
14
+ map "bound1", to: :bound1
15
+ map "bound2", to: :bound2
16
+ map "base_type", to: :base_type
21
17
  end
22
18
  end
23
19
  end
@@ -3,18 +3,15 @@ module Expressir
3
3
  module DataTypes
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 8.1.6 String data type
6
- class String < DataType
7
- model_attr_accessor :width, "Expression"
8
- model_attr_accessor :fixed, "::Boolean"
6
+ class String < ModelElement
7
+ attribute :width, ModelElement
8
+ attribute :fixed, :boolean
9
+ attribute :_class, :string, default: -> { send(:name) }
9
10
 
10
- # @param [Hash] options
11
- # @option options [Expression] :width
12
- # @option options [::Boolean] :fixed
13
- def initialize(options = {})
14
- @width = options[:width]
15
- @fixed = options[:fixed]
16
-
17
- super
11
+ key_value do
12
+ map "_class", to: :_class, render_default: true
13
+ map "width", to: :width
14
+ map "fixed", to: :fixed
18
15
  end
19
16
  end
20
17
  end
@@ -3,36 +3,27 @@ module Expressir
3
3
  module Declarations
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 9.2.1 Attributes
6
- class Attribute < Declaration
6
+ class Attribute < ModelElement
7
7
  include Identifier
8
8
 
9
- EXPLICIT = :EXPLICIT
10
- DERIVED = :DERIVED
11
- INVERSE = :INVERSE
9
+ EXPLICIT = "EXPLICIT".freeze
10
+ DERIVED = "DERIVED".freeze
11
+ INVERSE = "INVERSE".freeze
12
12
 
13
- model_attr_accessor :kind, ":EXPLICIT, :DERIVED, :INVERSE"
14
- model_attr_accessor :supertype_attribute, "Reference"
15
- model_attr_accessor :optional, "Boolean"
16
- model_attr_accessor :type, "DataType"
17
- model_attr_accessor :expression, "Expression"
13
+ attribute :kind, :string, values: %w[EXPLICIT DERIVED INVERSE]
14
+ attribute :supertype_attribute, ModelElement
15
+ attribute :optional, :boolean
16
+ attribute :type, ModelElement
17
+ attribute :expression, ModelElement
18
+ attribute :_class, :string, default: -> { send(:name) }
18
19
 
19
- # @param [Hash] options
20
- # @option (see Identifier#initialize_identifier)
21
- # @option options [:EXPLICIT, :DERIVED, :INVERSE] :kind
22
- # @option options [Reference] :supertype_attribute
23
- # @option options [Boolean] :optional
24
- # @option options [DataType] :type
25
- # @option options [Expression] :operand
26
- def initialize(options = {})
27
- initialize_identifier(options)
28
-
29
- @kind = options[:kind]
30
- @supertype_attribute = options[:supertype_attribute]
31
- @optional = options[:optional]
32
- @type = options[:type]
33
- @expression = options[:expression]
34
-
35
- super
20
+ key_value do
21
+ map "_class", to: :_class, render_default: true
22
+ map "kind", to: :kind
23
+ map "supertype_attribute", to: :supertype_attribute
24
+ map "optional", to: :optional
25
+ map "type", to: :type
26
+ map "expression", to: :expression
36
27
  end
37
28
 
38
29
  # @return [Array<Declaration>]
@@ -3,23 +3,17 @@ module Expressir
3
3
  module Declarations
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 9.4 Constant
6
- class Constant < Declaration
6
+ class Constant < ModelElement
7
7
  include Identifier
8
8
 
9
- model_attr_accessor :type, "DataType"
10
- model_attr_accessor :expression, "Expression"
9
+ attribute :type, ModelElement
10
+ attribute :expression, ModelElement
11
+ attribute :_class, :string, default: -> { send(:name) }
11
12
 
12
- # @param [Hash] options
13
- # @option (see Identifier#initialize_identifier)
14
- # @option options [DataType] :type
15
- # @option options [Expression] :expression
16
- def initialize(options = {})
17
- initialize_identifier(options)
18
-
19
- @type = options[:type]
20
- @expression = options[:expression]
21
-
22
- super
13
+ key_value do
14
+ map "_class", to: :_class, render_default: true
15
+ map "type", to: :type
16
+ map "expression", to: :expression
23
17
  end
24
18
 
25
19
  # @return [Array<Declaration>]
@@ -3,38 +3,27 @@ module Expressir
3
3
  module Declarations
4
4
  # Specified in ISO 10303-11:2004
5
5
  # - section 9.2 Entity declaration
6
- class Entity < Declaration
6
+ class Entity < ModelElement
7
7
  include Identifier
8
8
 
9
- model_attr_accessor :abstract, "Boolean"
10
- model_attr_accessor :supertype_expression, "SupertypeExpression"
11
- model_attr_accessor :subtype_of, "Array<Reference>"
12
- model_attr_accessor :attributes, "Array<Attribute>"
13
- model_attr_accessor :unique_rules, "Array<UniqueRule>"
14
- model_attr_accessor :where_rules, "Array<WhereRule>"
15
- model_attr_accessor :informal_propositions, "Array<RemarkItem>"
9
+ attribute :abstract, :boolean
10
+ attribute :supertype_expression, ModelElement
11
+ attribute :subtype_of, ModelElement, collection: true
12
+ attribute :attributes, Attribute, collection: true
13
+ attribute :unique_rules, UniqueRule, collection: true
14
+ attribute :where_rules, WhereRule, collection: true
15
+ attribute :informal_propositions, RemarkItem, collection: true
16
+ attribute :_class, :string, default: -> { send(:name) }
16
17
 
17
- # @param [Hash] options
18
- # @option (see Identifier#initialize_identifier)
19
- # @option options [Boolean] :abstract
20
- # @option options [SupertypeExpression] :supertype_expression
21
- # @option options [Array<Reference>] :subtype_of
22
- # @option options [Array<Attribute>] :attributes
23
- # @option options [Array<UniqueRule>] :unique_rules
24
- # @option options [Array<WhereRule>] :where_rules
25
- # @option options [Array<RemarkItem>] :informal_propositions
26
- def initialize(options = {})
27
- initialize_identifier(options)
28
-
29
- @abstract = options[:abstract]
30
- @supertype_expression = options[:supertype_expression]
31
- @subtype_of = options[:subtype_of] || []
32
- @attributes = options[:attributes] || []
33
- @unique_rules = options[:unique_rules] || []
34
- @where_rules = options[:where_rules] || []
35
- @informal_propositions = options[:informal_propositions] || []
36
-
37
- super
18
+ key_value do
19
+ map "_class", to: :_class, render_default: true
20
+ map "abstract", to: :abstract
21
+ map "supertype_expression", to: :supertype_expression
22
+ map "subtype_of", to: :subtype_of
23
+ map "attributes", to: :attributes
24
+ map "unique_rules", to: :unique_rules
25
+ map "where_rules", to: :where_rules
26
+ map "informal_propositions", to: :informal_propositions
38
27
  end
39
28
 
40
29
  # @return [Array<Declaration>]