class Oraora::Meta

Helper class wrapping OCI methods for querying metadata

Public Class Methods

new(oci) click to toggle source

Initializes with OCI

# File lib/oraora/meta.rb, line 8
def initialize(oci)
  @oci = oci
  @cache = {}
end

Public Instance Methods

find(context) click to toggle source

Returns a node identified by context

# 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) click to toggle source

Returns an object node identified by name

# File lib/oraora/meta.rb, line 30
def find_object(schema, name)
  Meta::Object.from_oci(@oci, schema, name)
end
purge_cache() click to toggle source

Removes all cached metadata

# File lib/oraora/meta.rb, line 35
def purge_cache
  @cache = {}
end