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(args) @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
27 28 29 30 31 32 33 |
# File 'lib/db_meta/oracle/types/grant.rb', line 27 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
35 36 37 |
# File 'lib/db_meta/oracle/types/grant.rb', line 35 def external_grant? @grantee == Connection.instance.username.upcase end |
#extract(args = {}) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/db_meta/oracle/types/grant.rb', line 18 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 |
# File 'lib/db_meta/oracle/types/grant.rb', line 13 def fetch(args={}) # definition is comma seperated in the name to prevent re-fetching table for every grant @grantee, @owner, @table_name, @grantor, @privilege, @grantable = @name.split(',') end |
#sort_value ⇒ Object
39 40 41 42 |
# File 'lib/db_meta/oracle/types/grant.rb', line 39 def sort_value return ["2", @grantor, @privilege, @table_name] if external_grant? return ["1", @grantee, @privilege, @table_name] end |