Class: MetaModel::Installer::Validator
- Inherits:
-
Object
- Object
- MetaModel::Installer::Validator
- Defined in:
- lib/metamodel/installer/validator.rb
Constant Summary collapse
- CURRENT_SUPPORTED_BUILT_IN_TYPES =
%w[ Int Double Float String Bool NSDate ]
Instance Method Summary collapse
Instance Method Details
#built_in_types ⇒ Object
38 39 40 41 42 |
# File 'lib/metamodel/installer/validator.rb', line 38 def built_in_types CURRENT_SUPPORTED_BUILT_IN_TYPES.map do |t| [t, "#{t}?"] end.flatten end |
#supported_types ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/metamodel/installer/validator.rb', line 44 def supported_types @models.reduce(CURRENT_SUPPORTED_BUILT_IN_TYPES) { |types, model| types << model.name.to_s }.map { |type| [type, "#{type}?"] }.flatten end |
#translate! ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/metamodel/installer/validator.rb', line 8 def translate! satisfy_constraint = @associations.reduce([]) do |remain, association| expect = remain.select { |assoc| assoc.expect_constraint? association } if expect.empty? remain << association else remain.delete expect.first end remain end raise Informative, "Unsatisfied constraints in #{satisfy_constraint.map \ { |x| x.debug_description }}" if satisfy_constraint.size > 0 end |
#validate_models ⇒ Object
23 24 25 26 27 |
# File 'lib/metamodel/installer/validator.rb', line 23 def validate_models existing_types = @models.map { |m| m.properties.map { |property| property.type } }.flatten.uniq unsupported_types = existing_types - supported_types raise Informative, "Unsupported types #{unsupported_types}" unless unsupported_types == [] end |