Class: CouchdbToSql::TableOperator
- Inherits:
-
Object
- Object
- CouchdbToSql::TableOperator
show all
- Defined in:
- lib/couchdb_to_sql/table_operator.rb
Overview
Abstract base class for classes which performs table operations (build, destroy, upsert, etc.)
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(parent, table_name, opts = {}) ⇒ TableOperator
17
18
19
20
21
22
|
# File 'lib/couchdb_to_sql/table_operator.rb', line 17
def initialize(parent, table_name, opts = {})
@parent = parent
@table_name = table_name
deduce_primary_key(opts)
end
|
Instance Attribute Details
9
10
11
|
# File 'lib/couchdb_to_sql/table_operator.rb', line 9
def parent
@parent
end
|
#primary_key ⇒ Symbol
15
16
17
|
# File 'lib/couchdb_to_sql/table_operator.rb', line 15
def primary_key
@primary_key
end
|
#table_name ⇒ String
12
13
14
|
# File 'lib/couchdb_to_sql/table_operator.rb', line 12
def table_name
@table_name
end
|
Instance Method Details
#deduce_primary_key(opts) ⇒ Object
24
25
26
|
# File 'lib/couchdb_to_sql/table_operator.rb', line 24
def deduce_primary_key(opts)
@primary_key = (opts[:primary_key] || "#{@table_name.to_s.singularize}_id").to_sym
end
|
#execute ⇒ Object
32
33
34
|
# File 'lib/couchdb_to_sql/table_operator.rb', line 32
def execute
raise NotImplementedError, "Classes deriving from #{self} must implement the 'execute' method."
end
|
#handler ⇒ Object
28
29
30
|
# File 'lib/couchdb_to_sql/table_operator.rb', line 28
def handler
parent.handler
end
|