Class: CouchdbToSql::TableOperator

Inherits:
Object
  • Object
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.)

Direct Known Subclasses

TableBuilder, TableDestroyer

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

#parentDocumentHandler (readonly)



9
10
11
# File 'lib/couchdb_to_sql/table_operator.rb', line 9

def parent
  @parent
end

#primary_keySymbol (readonly)



15
16
17
# File 'lib/couchdb_to_sql/table_operator.rb', line 15

def primary_key
  @primary_key
end

#table_nameString (readonly)



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

#executeObject

Raises:

  • (NotImplementedError)


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

#handlerObject



28
29
30
# File 'lib/couchdb_to_sql/table_operator.rb', line 28

def handler
  parent.handler
end