Class: Oraora::Meta

Inherits:
Object
  • Object
show all
Defined in:
lib/oraora/meta.rb,
lib/oraora/meta/view.rb,
lib/oraora/meta/table.rb,
lib/oraora/meta/column.rb,
lib/oraora/meta/object.rb,
lib/oraora/meta/schema.rb,
lib/oraora/meta/database.rb,
lib/oraora/meta/sequence.rb,
lib/oraora/meta/subprogram.rb,
lib/oraora/meta/materialized_view.rb

Overview

Helper class wrapping OCI methods for querying metadata

Defined Under Namespace

Classes: Column, Database, MaterializedView, NotApplicable, NotExists, Object, Schema, Sequence, Subprogram, Table, View

Instance Method Summary collapse

Constructor Details

#initialize(oci) ⇒ Meta

Initializes with OCI



8
9
10
11
# File 'lib/oraora/meta.rb', line 8

def initialize(oci)
  @oci = oci
  @cache = {}
end

Instance Method Details

#find(context) ⇒ Object

Returns a node identified by context



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/oraora/meta.rb', line 14

def find(context)
  node = case context.level
           when nil
             @cache[context] || Meta::Database.from_oci(@oci)
           when :schema
             @cache[context] || Meta::Schema.from_oci(@oci, context.schema)
           when :object
             @cache[context] || Meta::Object.from_oci(@oci, context.schema, context.object, context.object_type)
           when :column
             find(context.dup.up).columns(context.column)
         end
  @cache[context] = node if node && context.level != :column
  node
end

#find_object(schema, name) ⇒ Object

Returns an object node identified by name



30
31
32
# File 'lib/oraora/meta.rb', line 30

def find_object(schema, name)
  Meta::Object.from_oci(@oci, schema, name)
end

#purge_cacheObject

Removes all cached metadata



35
36
37
# File 'lib/oraora/meta.rb', line 35

def purge_cache
  @cache = {}
end