Class: DbMeta::Oracle::Base

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/db_meta/oracle/base.rb

Constant Summary collapse

TYPES =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helper

#block, #create_folder, #pluralize, #remove_folder, #type_sequence, #write_buffer_to_file

Constructor Details

#initialize(args = {}) ⇒ Base

Returns a new instance of Base.



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/db_meta/oracle/base.rb', line 25

def initialize(args = {})
  @type = args["OBJECT_TYPE"]
  @name = args["OBJECT_NAME"]

  @status = :unknown
  @status = args["STATUS"].downcase.to_sym if args["STATUS"]

  @extract_type = :default # :default, :embedded, :merged

  @system_object = /\$/i.match?(@name) # true if there is a '$' in the object name
end

Instance Attribute Details

#extract_typeObject

Returns the value of attribute extract_type.



8
9
10
# File 'lib/db_meta/oracle/base.rb', line 8

def extract_type
  @extract_type
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/db_meta/oracle/base.rb', line 8

def name
  @name
end

#statusObject

Returns the value of attribute status.



8
9
10
# File 'lib/db_meta/oracle/base.rb', line 8

def status
  @status
end

#system_objectObject

Returns the value of attribute system_object.



8
9
10
# File 'lib/db_meta/oracle/base.rb', line 8

def system_object
  @system_object
end

#typeObject

Returns the value of attribute type.



8
9
10
# File 'lib/db_meta/oracle/base.rb', line 8

def type
  @type
end

Class Method Details

.from_type(args = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/db_meta/oracle/base.rb', line 14

def self.from_type(args = {})
  type = args["OBJECT_TYPE"]

  # return instance of known type
  return TYPES[type].new(args) if TYPES.key?(type)

  # There is no implementation for this type yet. Let's just use Base
  Log.warn("Don't know how to handle oracle type [#{type}] yet")
  Base.new(args)
end

.register_type(type) ⇒ Object



10
11
12
# File 'lib/db_meta/oracle/base.rb', line 10

def self.register_type(type)
  TYPES[type] = self
end

Instance Method Details

#ddl_dropObject



44
45
46
# File 'lib/db_meta/oracle/base.rb', line 44

def ddl_drop
  "DROP #{@type} #{@name};"
end

#extract(args = {}) ⇒ Object



40
41
42
# File 'lib/db_meta/oracle/base.rb', line 40

def extract(args = {})
  "-- class/method needs to be implemented"
end

#fetchObject



37
38
# File 'lib/db_meta/oracle/base.rb', line 37

def fetch
end

#system_object?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/db_meta/oracle/base.rb', line 48

def system_object?
  @system_object
end