Class: SurrealDB::Table
- Inherits:
-
Object
- Object
- SurrealDB::Table
- Defined in:
- lib/surrealdb/models/table.rb
Overview
Wraps a table name to distinguish table-level operations from record-level operations that take a string "table:id".
Instance Attribute Summary collapse
- #name ⇒ String readonly
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name) ⇒ Table
constructor
A new instance of Table.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ Table
Returns a new instance of Table.
11 12 13 14 15 |
# File 'lib/surrealdb/models/table.rb', line 11 def initialize(name) raise ArgumentError, 'table name must be a non-empty string' if name.nil? || name.empty? @name = name.freeze end |
Instance Attribute Details
#name ⇒ String (readonly)
8 9 10 |
# File 'lib/surrealdb/models/table.rb', line 8 def name @name end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
25 26 27 |
# File 'lib/surrealdb/models/table.rb', line 25 def ==(other) other.is_a?(Table) && other.name == @name end |
#hash ⇒ Object
30 31 32 |
# File 'lib/surrealdb/models/table.rb', line 30 def hash [self.class, @name].hash end |
#inspect ⇒ Object
21 22 23 |
# File 'lib/surrealdb/models/table.rb', line 21 def inspect "SurrealDB::Table(#{@name})" end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/surrealdb/models/table.rb', line 17 def to_s @name end |