Module: RGen::Instantiator::ResolutionHelper
- Defined in:
- lib/rgen/instantiator/resolution_helper.rb
Class Method Summary collapse
- .is_type_error?(e) ⇒ Boolean
-
.set_uref_target(uref, target) ⇒ Object
sets the target of an unresolved reference in the model returns :type_error if the target is of wrong type, otherwise :success.
Class Method Details
.is_type_error?(e) ⇒ Boolean
39 40 41 |
# File 'lib/rgen/instantiator/resolution_helper.rb', line 39 def self.is_type_error?(e) e. =~ /Can not use a .* where a .* is expected/ end |
.set_uref_target(uref, target) ⇒ Object
sets the target of an unresolved reference in the model returns :type_error if the target is of wrong type, otherwise :success
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 |
# File 'lib/rgen/instantiator/resolution_helper.rb', line 9 def self.set_uref_target(uref, target) refs = uref.element.getGeneric(uref.feature_name) if refs.is_a?(Array) index = refs.index(uref.proxy) uref.element.removeGeneric(uref.feature_name, uref.proxy) begin uref.element.addGeneric(uref.feature_name, target, index) rescue StandardError => e if is_type_error?(e) uref.element.addGeneric(uref.feature_name, uref.proxy, index) return :type_error else raise end end else begin # this will replace the proxy uref.element.setGeneric(uref.feature_name, target) rescue StandardError => e if is_type_error?(e) return :type_error else raise end end end :success end |