Sha256: d2185b05a3dd487d11ee2695d2e3665fd5a77262a402d221061aaec6a837c0fc

Contents?: true

Size: 1.4 KB

Versions: 4

Compression:

Stored size: 1.4 KB

Contents

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 :topic_map_construct, :type => :TopicMapConstruct, :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-0.1.4 lib/rtm/backend/active_record/locators.rb
rtm-0.1.3 lib/rtm/backend/active_record/locators.rb
rtm-0.1.5 lib/rtm/backend/active_record/locators.rb
rtm-0.1.6 lib/rtm/backend/active_record/locators.rb