# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 unless Object.const_defined?("Gem") && rtmgem = Gem.loaded_specs["rtm-activerecord"] rtm_path = File.expand_path(File.join(File.dirname(__FILE__), "../../../rtm/lib")) $LOAD_PATH.unshift rtm_path if File.directory?(rtm_path) end require 'rtm' require 'uri' require "rtm/activerecord/tmdm" require "rtm/activerecord/persistent_code_output" require "rtm/activerecord/tm_delegator" require "rtm/activerecord/tm_set_delegator" require "rtm/activerecord/tm_construct" require "rtm/activerecord/topic_map" require "rtm/activerecord/traverse_associations" require "rtm/activerecord/topic" require "rtm/activerecord/association_and_role" require "rtm/activerecord/name_variant_occurrence" require "rtm/activerecord/locators" require "rtm/activerecord/set_wrapper" require "rtm/activerecord/base" require "rtm/activerecord/literal_index" require "rtm/activerecord/topic_map_system" require "rtm/validation" require "rtm/helpers/locator" require "rtm/helpers/no_output" require "rtm/helpers/uri" module RTM::AR module TraverseAssociations end class Topic require 'rtm/activerecord/sugar/topic/characteristics' require 'rtm/activerecord/sugar/topic/counterparts' require 'rtm/activerecord/sugar/topic/identifier_direct' require 'rtm/activerecord/sugar/topic/hash_access' require 'rtm/activerecord/sugar/topic/predefined_associations' require "rtm/activerecord/io/to_xtm2" require "rtm/activerecord/io/to_xtm1" require "rtm/activerecord/io/to_yaml" require "rtm/activerecord/io/to_string" require "rtm/activerecord/io/to_jtm" include RTM::AR::Sugar::Topic::Characteristics include RTM::AR::Sugar::Topic::Counterparts include RTM::AR::Sugar::Topic::IdentifierDirect include RTM::AR::Sugar::Topic::HashAccess include RTM::AR::Sugar::Topic::PredefinedAssociations end class Association require 'rtm/activerecord/sugar/association/hash_access' require 'rtm/activerecord/sugar/role/counterparts' include RTM::AR::Sugar::Association::HashAccess include RTM::AR::Sugar::Role::Counterparts end class ActiveRecord < RTM::Engine identifier :activerecord include RTM::AR::TopicMapSystem def initialize(params) super config = @params[:config] case config when :existing # do nothing, reuse existing active_record connection when nil # use the existing or externally configured connection connect unless connected? when :memory # explicityly connect to the sqlite3 in-memory backend connect when ::ActiveRecord::Base # when it is a class which extends ActiveRecord::Base, use the connection of this one. # FIXME: this is not implemented yet. when Array connect *config when Hash connect config else # fall through, like :existing end end end end