Class: PgObjects::DbObject
- Inherits:
-
Object
- Object
- PgObjects::DbObject
- Includes:
- Memery
- Defined in:
- lib/pg_objects/db_object.rb
Overview
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 [qualified_object_name] schema-qualified object name (+schema.name+) when a schema is present, otherwise same as object_name; nil if parsing failed
Instance Attribute Summary collapse
-
#full_name ⇒ Object
readonly
Returns the value of attribute full_name.
-
#object_name ⇒ Object
readonly
Returns the value of attribute object_name.
-
#qualified_object_name ⇒ Object
readonly
Returns the value of attribute qualified_object_name.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #create ⇒ Object
- #dependencies ⇒ Object
-
#initialize(path, status = :new, parser:) ⇒ DbObject
constructor
A new instance of DbObject.
- #name ⇒ Object
- #sql_query ⇒ Object
Constructor Details
#initialize(path, status = :new, parser:) ⇒ DbObject
Returns a new instance of DbObject.
19 20 21 22 23 |
# File 'lib/pg_objects/db_object.rb', line 19 def initialize(path, status = :new, parser:) @full_name = path @status = status @parser = parser end |
Instance Attribute Details
#full_name ⇒ Object (readonly)
Returns the value of attribute full_name.
17 18 19 |
# File 'lib/pg_objects/db_object.rb', line 17 def full_name @full_name end |
#object_name ⇒ Object (readonly)
Returns the value of attribute object_name.
17 18 19 |
# File 'lib/pg_objects/db_object.rb', line 17 def object_name @object_name end |
#qualified_object_name ⇒ Object (readonly)
Returns the value of attribute qualified_object_name.
17 18 19 |
# File 'lib/pg_objects/db_object.rb', line 17 def qualified_object_name @qualified_object_name end |
#status ⇒ Object
Returns the value of attribute status.
16 17 18 |
# File 'lib/pg_objects/db_object.rb', line 16 def status @status end |
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/pg_objects/db_object.rb', line 25 def create parser.load(sql_query) @object_name = parser.fetch_object_name @qualified_object_name = parser.fetch_qualified_object_name @status = :pending self end |
#dependencies ⇒ Object
40 41 42 |
# File 'lib/pg_objects/db_object.rb', line 40 def dependencies parser.fetch_directives[:depends_on] end |
#name ⇒ Object
35 36 37 |
# File 'lib/pg_objects/db_object.rb', line 35 def name File.basename(full_name, '.*') end |
#sql_query ⇒ Object
45 46 47 |
# File 'lib/pg_objects/db_object.rb', line 45 def sql_query File.read(full_name) end |