Sha256: 0e6f1df9c82ac7865f2088f560b00373a281034d0bd8d6331f11ce3ee7008eeb

Contents?: true

Size: 1.49 KB

Versions: 4

Compression:

Stored size: 1.49 KB

Contents

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

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

    delegate :+
    delegate :-
    #delegate :==
    delegate :id

    delegate :get
    delegate :hash
    delegate :resolve_relative
    delegate :to_s, :to => :reference
    delegate :to_uri
    delegate :uri
    delegate :reference, :rw => true, :save => true
    alias :value :reference
    alias :value= :reference=
    alias :v :reference
    alias :v= :reference=

    equality [:reference]

    def self.wrap(obj)
      return nil unless obj
      raise "Double wrapping" if obj.respond_to?(:__getobj__)
      case obj.class.name
      when "RTM::AR::TMDM::ItemIdentifier"
        ItemIdentifier.wrap(obj)
      when "RTM::AR::TMDM::SubjectIdentifier"
        SubjectIdentifier.wrap(obj)
      when "RTM::AR::TMDM::SubjectLocator"
        SubjectLocator.wrap(obj)
      else
        raise "Can't wrap object. Class for wrapping #{obj.class} unknown (object: #{obj})"
      end
    end
  end

  class ItemIdentifier < Locator
    include RTM::ItemIdentifier
    wrapper_cache
    property :construct, :type => :Construct, :wrap => true
  end
  class SubjectIdentifier < Locator
    include RTM::SubjectIdentifier
    wrapper_cache
    property :topic, :type => :Topic, :wrap => true
  end
  class SubjectLocator < Locator
    include RTM::SubjectLocator
    wrapper_cache
    property :topic, :type => :Topic, :wrap => true    
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rtm-activerecord-0.3.1 lib/rtm/activerecord/locators.rb
rtm-activerecord-0.3.0 lib/rtm/activerecord/locators.rb
rtm-activerecord-0.2.1 lib/rtm/activerecord/locators.rb
rtm-activerecord-0.2.0 lib/rtm/activerecord/locators.rb