module MarkMapper::Plugins::Persistence::ClassMethods

Public Instance Methods

collection() click to toggle source
# File lib/mark_mapper/plugins/persistence.rb, line 56
def collection
  assert_supported
  database.collection(collection_name)
end
collection_name() click to toggle source
# File lib/mark_mapper/plugins/persistence.rb, line 47
def collection_name
  assert_supported
  @collection_name ||= begin
    name = self.to_s.tableize.gsub(/\//, '.')
    name = self.class.to_s.downcase if name[0] == '#'
    name
  end
end
connection(marklogic_connection=nil) click to toggle source
# File lib/mark_mapper/plugins/persistence.rb, line 17
def connection(marklogic_connection=nil)
  assert_supported
  if marklogic_connection.nil? && MarkMapper.connection?
    @connection ||= MarkMapper.connection
  else
    @connection = marklogic_connection
  end
  @connection
end
database() click to toggle source
# File lib/mark_mapper/plugins/persistence.rb, line 37
def database
  assert_supported
  @database ||= MarkMapper.application.content_databases[0]
end
database=(database) click to toggle source
# File lib/mark_mapper/plugins/persistence.rb, line 32
def database=(database)
  assert_supported
  @database = database
end
database_name() click to toggle source
# File lib/mark_mapper/plugins/persistence.rb, line 27
def database_name
  assert_supported
  @database.database_name
end
inherited(subclass) click to toggle source
Calls superclass method
# File lib/mark_mapper/plugins/persistence.rb, line 8
def inherited(subclass)
  unless subclass.embeddable?
    subclass.connection(connection)
    subclass.database = database
    subclass.set_collection_name(collection_name) unless subclass.explicit_collection_defined?
  end
  super
end
set_collection_name(name) click to toggle source
# File lib/mark_mapper/plugins/persistence.rb, line 42
def set_collection_name(name)
  assert_supported
  @collection_name = name
end

Private Instance Methods

assert_supported() click to toggle source
# File lib/mark_mapper/plugins/persistence.rb, line 62
def assert_supported
  @embeddable ||= embeddable?
  if @embeddable
    raise MarkMapper::NotSupported.new('This is not supported for embeddable documents at this time.')
  end
end