Module: Rethinker::Document::Core::ClassMethods
- Defined in:
- lib/rethinker/document/core.rb
Instance Method Summary collapse
-
#ensure_table! ⇒ Object
Thread safe because the operation is idempotent (no error if we try to create the table twice).
-
#table ⇒ Object
Even though we are using class variables, it’s threads-safe.
- #table_name ⇒ Object
Instance Method Details
#ensure_table! ⇒ Object
Thread safe because the operation is idempotent (no error if we try to create the table twice)
31 32 33 34 35 |
# File 'lib/rethinker/document/core.rb', line 31 def ensure_table! root_class.class_eval do @table_created ||= !!self.count end end |
#table ⇒ Object
Even though we are using class variables, it’s threads-safe. It’s still racy, but the race is harmless.
23 24 25 26 27 |
# 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 ⇒ Object
17 18 19 |
# File 'lib/rethinker/document/core.rb', line 17 def table_name root_class.name.underscore.gsub('/', '__').pluralize end |