Class: OCI8::Metadata::Schema

Inherits:
Base
  • Object
show all
Defined in:
lib/oci8/metadata.rb

Overview

Metadata for a schema.

This is returned by:

  • OCI8#describe_schema(schema_name)

  • OCI8::Metadata::Database#schemas

Instance Method Summary collapse

Methods inherited from Base

#obj_id, #obj_link, #obj_name, #obj_schema

Instance Method Details

#all_objectsObject

array of objects in the schema. This includes unusable objects.



1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
# File 'lib/oci8/metadata.rb', line 1715

def all_objects
  @all_objects ||=
    begin
      begin
        objs = list_objects
      rescue OCIError => exc
        if exc.code != -1
          raise
        end
        # describe again.
        objs = __con.describe_schema(obj_schema).list_objects
      end
      objs.to_a.collect! do |elem|
        case elem
        when OCI8::Metadata::Type
          # to avoid a segmentation fault
          begin
            __con.describe_type(elem.obj_schema + '.' + elem.obj_name)
          rescue OCIError
            # ignore ORA-24372: invalid object for describe
            raise if $!.code != 24372
          end
        else
          elem
        end
      end.compact
    end
end

#inspectObject

:nodoc:



1763
1764
1765
# File 'lib/oci8/metadata.rb', line 1763

def inspect # :nodoc:
  "#<#{self.class.name}:(#{obj_id}) #{obj_schema}>"
end

#objectsObject

array of objects in the schema.



1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
# File 'lib/oci8/metadata.rb', line 1745

def objects
  @objects ||= all_objects.reject do |obj|
    case obj
    when Unknown
      true
    when Synonym
      begin
        obj.objid
        false
      rescue OCIError
        true
      end
    else
      false
    end
  end
end