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_name, #obj_schema

Instance Method Details

#all_objectsObject

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



1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
# File 'lib/oci8/metadata.rb', line 1679

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:



1727
1728
1729
# File 'lib/oci8/metadata.rb', line 1727

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

#objectsObject

array of objects in the schema.



1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
# File 'lib/oci8/metadata.rb', line 1709

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