Sha256: cdcaad9ff8741447cab7857c31c486f53ae270961b2b7a9864e67ff1fb329f53

Contents?: true

Size: 628 Bytes

Versions: 4

Compression:

Stored size: 628 Bytes

Contents

# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
# License:   Apache License, Version 2.0

module RTM::AR::Sugar
  module Topic
    module Counterparts
      def counterparts(filter={})
        self.roles.
             select{|r| filter[:rtype] ? r.type == self.topic_map.get(filter[:rtype]) : true}.
             select{|r| filter[:atype] ? r.parent.type == self.topic_map.get(filter[:atype]) : true}.
             inject([]){|all,r| all+=r.counterparts(filter)}                  
      end
      def counterplayers(*args)
        return self.counterparts(*args).map{|r| r.player}
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rtm-activerecord-0.3.1 lib/rtm/activerecord/sugar/topic/counterparts.rb
rtm-activerecord-0.3.0 lib/rtm/activerecord/sugar/topic/counterparts.rb
rtm-activerecord-0.2.1 lib/rtm/activerecord/sugar/topic/counterparts.rb
rtm-activerecord-0.2.0 lib/rtm/activerecord/sugar/topic/counterparts.rb