Class: Webhookdb::Tasks::Admin
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Webhookdb::Tasks::Admin
- Defined in:
- lib/webhookdb/tasks/admin.rb
Instance Method Summary collapse
- #find_org(args) ⇒ Object
-
#initialize ⇒ Admin
constructor
A new instance of Admin.
- #setup ⇒ Object
Constructor Details
#initialize ⇒ Admin
Returns a new instance of Admin.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/webhookdb/tasks/admin.rb', line 9 def initialize super() namespace :admin do desc "Add roles to the named org" task :role, [:org_key, :role] do |_, args| self.setup org = self.find_org(args) role = Webhookdb::Role.find_or_create(name: args.fetch(:role)) org.add_feature_role(role) puts "Added role #{role.name} to #{org.name}" end task :backfill, [:org_key] do |_, args| self.setup org = self.find_org(args) org.service_integrations.each do |sint| Webhookdb::BackfillJob.create(service_integration: sint, incremental: false).enqueue end end task :connection, [:org_key, :type] do |_, args| self.setup org = self.find_org(args) type = args.fetch(:type, "readonly") puts org.send(:"#{type}_connection_url") end end end |
Instance Method Details
#find_org(args) ⇒ Object
43 44 45 46 47 |
# File 'lib/webhookdb/tasks/admin.rb', line 43 def find_org(args) org_key = args.fetch(:org_key) org = Webhookdb::Organization[key: org_key] or raise "No org with key #{org_key}" return org end |