Class: Mkxms::Mssql::Permission

Inherits:
Object
  • Object
show all
Defined in:
lib/mkxms/mssql/permission_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ Permission

Returns a new instance of Permission.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/mkxms/mssql/permission_handler.rb', line 53

def initialize(attrs)
  @name = attrs['name']
  @target_type = attrs['target-type']
  @name_scope = attrs['name-scope']
  @schema = attrs['in-schema']
  @object = attrs['on']
  @column = attrs['column']
  @target = if @object
    "".tap do |subject|
      if @schema
        subject << (@schema + '.')
      end
      subject << @object
      subject << " (#@column)" if @column
    end
  else
    'DATABASE'
  end
  @grant_option = attrs['with-grant-option']
  @authority = attrs['by']
end

Instance Attribute Details

#authorityObject

Returns the value of attribute authority.



75
76
77
# File 'lib/mkxms/mssql/permission_handler.rb', line 75

def authority
  @authority
end

#columnObject

Returns the value of attribute column.



75
76
77
# File 'lib/mkxms/mssql/permission_handler.rb', line 75

def column
  @column
end

#nameObject

Returns the value of attribute name.



75
76
77
# File 'lib/mkxms/mssql/permission_handler.rb', line 75

def name
  @name
end

#name_scopeObject

Returns the value of attribute name_scope.



75
76
77
# File 'lib/mkxms/mssql/permission_handler.rb', line 75

def name_scope
  @name_scope
end

#target_typeObject

Returns the value of attribute target_type.



75
76
77
# File 'lib/mkxms/mssql/permission_handler.rb', line 75

def target_type
  @target_type
end

Instance Method Details

#grant_option=(value) ⇒ Object



92
93
94
# File 'lib/mkxms/mssql/permission_handler.rb', line 92

def grant_option=(value)
  @grant_option = value
end

#grant_option?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/mkxms/mssql/permission_handler.rb', line 89

def grant_option?
  @grant_option
end

#object_id_partsObject



96
97
98
# File 'lib/mkxms/mssql/permission_handler.rb', line 96

def object_id_parts
  [@target_type, @schema, @object, @column]
end

#target(scoped: true) ⇒ Object



77
78
79
80
81
82
83
# File 'lib/mkxms/mssql/permission_handler.rb', line 77

def target(scoped: true)
  if scoped && @name_scope
    "#@name_scope :: #@target"
  else
    @target
  end
end

#unscoped_targetObject



85
86
87
# File 'lib/mkxms/mssql/permission_handler.rb', line 85

def unscoped_target
  target(scoped: false)
end