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
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.
-
#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.
15 16 17 18 19 |
# File 'lib/pg_objects/db_object.rb', line 15 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.
13 14 15 |
# File 'lib/pg_objects/db_object.rb', line 13 def full_name @full_name end |
#object_name ⇒ Object (readonly)
Returns the value of attribute object_name.
13 14 15 |
# File 'lib/pg_objects/db_object.rb', line 13 def object_name @object_name end |
#status ⇒ Object
Returns the value of attribute status.
12 13 14 |
# File 'lib/pg_objects/db_object.rb', line 12 def status @status end |
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/pg_objects/db_object.rb', line 21 def create parser.load(sql_query) @object_name = parser.fetch_object_name @status = :pending self end |
#dependencies ⇒ Object
35 36 37 |
# File 'lib/pg_objects/db_object.rb', line 35 def dependencies parser.fetch_directives[:depends_on] end |
#name ⇒ Object
30 31 32 |
# File 'lib/pg_objects/db_object.rb', line 30 def name File.basename(full_name, '.*') end |
#sql_query ⇒ Object
40 41 42 |
# File 'lib/pg_objects/db_object.rb', line 40 def sql_query File.read(full_name) end |