Class: Organizations::Groups::TransferValidator

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/services/organizations/groups/transfer_validator.rb

Instance Method Summary collapse

Constructor Details

#initialize(group:, new_organization:, current_user:) ⇒ TransferValidator

Returns a new instance of TransferValidator.



8
9
10
11
12
# File 'app/services/organizations/groups/transfer_validator.rb', line 8

def initialize(group:, new_organization:, current_user:)
  @group = group
  @new_organization = new_organization
  @current_user = current_user
end

Instance Method Details

#can_transfer?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/services/organizations/groups/transfer_validator.rb', line 14

def can_transfer?
  error_message.nil?
end

#error_messageObject



18
19
20
21
22
23
24
# File 'app/services/organizations/groups/transfer_validator.rb', line 18

def error_message
  return localized_error_messages[:group_not_root] unless group_is_root?
  return localized_error_messages[:same_organization] if same_organization?
  return localized_error_messages[:permission] unless has_permission?

  nil
end