module Rethinker::Document::Core::ClassMethods

Public Instance Methods

ensure_table!() click to toggle source

Thread safe because the operation is idempotent (no error if we try to create the table twice)

# File lib/rethinker/document/core.rb, line 31
def ensure_table!
  root_class.class_eval do
    @table_created ||= !!self.count
  end
end
table() click to toggle source

Even though we are using class variables, it’s threads-safe. It’s still racy, but the race is harmless.

# File lib/rethinker/document/core.rb, line 23
def table
  root_class.class_eval do
    @table ||= RethinkDB::RQL.new.table(table_name).freeze
  end
end
table_name() click to toggle source
# File lib/rethinker/document/core.rb, line 17
def table_name
  root_class.name.underscore.gsub('/', '__').pluralize
end