Sha256: 9289230ec6c05379c6a6eb88c39a965e4176c687744ed87603ba0b655e632d47

Contents?: true

Size: 1.7 KB

Versions: 5

Compression:

Stored size: 1.7 KB

Contents

module RTM::AR
  class TopicMapConstruct < TMDelegator
    include RTM::TopicMapConstruct

    def self.abstract_class?
      self == TopicMapConstruct
    end
    property_set :item_identifiers, :aka => [:ii, :iid, :source_locators], :type => :ItemIdentifier, :wrap => true,
      #:create => :item_identifier, :create_aka => :cii
      :add => true, :remove => true

    delegate :remove, :to => :destroy

    delegate :id
    #    property_parent :parent # mmh..

    property :topic_map, :rw => true, :type => :TopicMap, :wrap => true

    #class_delegate :create

    def self.wrap(obj)
      return nil unless obj
      raise "Double wrapping" if obj.respond_to?(:__getobj__)
      case obj.class.name
      when "RTM::AR::TMDM::Topic"
        Topic.wrap(obj)
      when "RTM::AR::TMDM::Variant"
        Variant.wrap(obj)
      when "RTM::AR::TMDM::TopicName"
        TopicName.wrap(obj)
      when "RTM::AR::TMDM::Occurrence"
        Occurrence.wrap(obj)
      when "RTM::AR::TMDM::Association"
        Association.wrap(obj)
      when "RTM::AR::TMDM::AssociationRole"
        AssociationRole.wrap(obj)
      when "RTM::AR::TMDM::TopicMap"
        TopicMap.wrap(obj)
      else
        raise "Can't wrap object. Class for wrapping #{obj.class} unknown (object: #{obj})"
      end
    end
    
    def self.find(*args)
      res = RTM::AR::TMDM.const_get(name.split("::").last).find(*args)
      if res.respond_to? :each
        TopicMapConstructs.wrap(res)
      else
        TopicMapConstruct.wrap(res)
      end
    end
  end

  class Reifiable < TopicMapConstruct
    include RTM::Reifiable

    def self.abstract_class?
      self == Reifiable
    end
    property :reifier, :type => :Topic, :rw => :true, :wrap => true
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rtm-0.1.1 lib/rtm/backend/active_record/tm_construct.rb
rtm-0.1.4 lib/rtm/backend/active_record/tm_construct.rb
rtm-0.1.5 lib/rtm/backend/active_record/tm_construct.rb
rtm-0.1.3 lib/rtm/backend/active_record/tm_construct.rb
rtm-0.1.6 lib/rtm/backend/active_record/tm_construct.rb