Class: Decidim::Voca::Organization::UpdatePermissionCommand

Inherits:
OrganizationCommand show all
Defined in:
app/commands/decidim/voca/organization/update_permission_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from OrganizationCommand

#command_name, command_name, #organization

Constructor Details

#initialize(permission_settings) ⇒ UpdatePermissionCommand

Returns a new instance of UpdatePermissionCommand.



6
7
8
# File 'app/commands/decidim/voca/organization/update_permission_command.rb', line 6

def initialize(permission_settings)
  @permission_settings = cast_permission_settings(permission_settings.to_h)
end

Instance Attribute Details

#permission_settingsObject (readonly)

Returns the value of attribute permission_settings.



5
6
7
# File 'app/commands/decidim/voca/organization/update_permission_command.rb', line 5

def permission_settings
  @permission_settings
end

Instance Method Details

#callObject



10
11
12
13
14
15
16
# File 'app/commands/decidim/voca/organization/update_permission_command.rb', line 10

def call
  organization.update!(permission_settings.delete_if { |_k, v| v.blank? })
  broadcast(:ok)
rescue e
  Rails.logger.error(e)
  broadcast(:fail)
end