Sha256: ed5b6b6868a029a490e229379b5cf5e1f19292eb898c017b86a166af04d01354

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

##
# Represents DB object as it is described in file
#
# [name]  name of file without extension
# [full_name] full pathname of file
# [object_name] name of function, trigger etc. if it was successfully parsed, otherwise - nil
class PgObjects::DbObject
  attr_reader :sql_query, :name, :full_name, :object_name, :dependencies
  attr_accessor :status

  def initialize(file_path)
    @full_name = file_path
    @name = File.basename(file_path, '.*')

    @status = :new
  end

  def create
    @sql_query = File.read(full_name)

    parser = PgObjects::Parser.new(sql_query)

    directives = parser.fetch_directives
    @dependencies = directives[:depends_on]
    @object_name = parser.fetch_object_name

    @status = :pending

    self
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pg_objects-1.2.0 lib/pg_objects/db_object.rb