Class: DbMeta::Oracle::Grant
- Defined in:
- lib/db_meta/oracle/types/grant.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#grantable ⇒ Object
readonly
Returns the value of attribute grantable.
-
#grantee ⇒ Object
readonly
Returns the value of attribute grantee.
-
#grantor ⇒ Object
readonly
Returns the value of attribute grantor.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#privilege ⇒ Object
readonly
Returns the value of attribute privilege.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
Attributes inherited from Base
#extract_type, #name, #status, #system_object, #type
Instance Method Summary collapse
- #ddl_drop ⇒ Object
- #external_grant? ⇒ Boolean
- #extract(args = {}) ⇒ Object
- #fetch(args = {}) ⇒ Object
-
#initialize(args = {}) ⇒ Grant
constructor
A new instance of Grant.
- #sort_value ⇒ Object
Methods inherited from Base
from_type, register_type, #system_object?
Methods included from Helper
#block, #create_folder, #pluralize, #remove_folder, #type_sequence, #write_buffer_to_file
Constructor Details
#initialize(args = {}) ⇒ Grant
Returns a new instance of Grant.
8 9 10 11 |
# File 'lib/db_meta/oracle/types/grant.rb', line 8 def initialize(args = {}) super @extract_type = :merged end |
Instance Attribute Details
#grantable ⇒ Object (readonly)
Returns the value of attribute grantable.
6 7 8 |
# File 'lib/db_meta/oracle/types/grant.rb', line 6 def grantable @grantable end |
#grantee ⇒ Object (readonly)
Returns the value of attribute grantee.
6 7 8 |
# File 'lib/db_meta/oracle/types/grant.rb', line 6 def grantee @grantee end |
#grantor ⇒ Object (readonly)
Returns the value of attribute grantor.
6 7 8 |
# File 'lib/db_meta/oracle/types/grant.rb', line 6 def grantor @grantor end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
6 7 8 |
# File 'lib/db_meta/oracle/types/grant.rb', line 6 def owner @owner end |
#privilege ⇒ Object (readonly)
Returns the value of attribute privilege.
6 7 8 |
# File 'lib/db_meta/oracle/types/grant.rb', line 6 def privilege @privilege end |
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
6 7 8 |
# File 'lib/db_meta/oracle/types/grant.rb', line 6 def table_name @table_name end |
Instance Method Details
#ddl_drop ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/db_meta/oracle/types/grant.rb', line 29 def ddl_drop buffer = "" buffer << ("%-30s" % "-- granted via #{@grantor}: ") if external_grant? buffer << "REVOKE #{"%-18s" % @privilege} ON #{"%-32s" % @table_name} FROM #{@grantee};" buffer end |
#external_grant? ⇒ Boolean
37 38 39 |
# File 'lib/db_meta/oracle/types/grant.rb', line 37 def external_grant? @external_grant end |
#extract(args = {}) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/db_meta/oracle/types/grant.rb', line 20 def extract(args = {}) buffer = "" buffer << ("%-30s" % "-- granted via #{@grantor}: ") if external_grant? buffer << "GRANT #{"%-18s" % @privilege} ON #{"%-32s" % @table_name} TO #{@grantee}" buffer << " WITH GRANT OPTION" if @grantable == "YES" buffer << ";" buffer end |
#fetch(args = {}) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/db_meta/oracle/types/grant.rb', line 13 def fetch(args = {}) connection_class = args[:connection_class] || Connection # definition is comma seperated in the name to prevent re-fetching table for every grant @grantee, @owner, @table_name, @grantor, @privilege, @grantable = @name.split(",") @external_grant = @grantor != connection_class.instance.username.upcase end |
#sort_value ⇒ Object
41 42 43 44 |
# File 'lib/db_meta/oracle/types/grant.rb', line 41 def sort_value return ["2", @grantor, @privilege, @table_name] if external_grant? ["1", @grantee, @privilege, @table_name] end |