Class: RText::DefaultResolver
- Inherits:
-
Object
- Object
- RText::DefaultResolver
- Defined in:
- lib/rtext/default_resolver.rb
Instance Method Summary collapse
- #find_targets(uref, model) ⇒ Object
-
#initialize(lang) ⇒ DefaultResolver
constructor
A new instance of DefaultResolver.
- #resolve_fragment(fragment) ⇒ Object
- #resolve_model(model) ⇒ Object
Constructor Details
#initialize(lang) ⇒ DefaultResolver
Returns a new instance of DefaultResolver.
5 6 7 |
# File 'lib/rtext/default_resolver.rb', line 5 def initialize(lang) @lang = lang end |
Instance Method Details
#find_targets(uref, model) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rtext/default_resolver.rb', line 25 def find_targets(uref, model) @lang.reference_qualifier.call([uref], model) identifier = uref.proxy.targetIdentifier targets = model.index[identifier] targets ||= [] if @lang.per_type_identifier feature = @lang.feature_by_name(uref.element.class.ecore, uref.feature_name) if feature targets = targets.select{|t| t.is_a?(feature.eType.instanceClass)} end end targets end |
#resolve_fragment(fragment) ⇒ Object
9 10 11 12 13 |
# File 'lib/rtext/default_resolver.rb', line 9 def resolve_fragment(fragment) @lang.reference_qualifier.call(fragment.unresolved_refs, fragment) fragment.resolve_local( :use_target_type => @lang.per_type_identifier) end |
#resolve_model(model) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/rtext/default_resolver.rb', line 15 def resolve_model(model) @lang.reference_qualifier.call(model.unresolved_refs, model) model.resolve( :fragment_provider => proc {|e| fr = @lang.fragment_ref(e) fr && fr.fragment }, :use_target_type => @lang.per_type_identifier) end |