erp_tech_svcs 4.0.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -24
  3. data/app/controllers/api/v1/audit_log_items_controller.rb +33 -0
  4. data/app/controllers/api/v1/audit_logs_controller.rb +32 -0
  5. data/app/controllers/api/v1/capabilities_controller.rb +160 -0
  6. data/app/controllers/api/v1/file_assets_controller.rb +40 -0
  7. data/app/controllers/api/v1/groups_controller.rb +236 -0
  8. data/app/controllers/api/v1/security_roles_controller.rb +276 -0
  9. data/app/controllers/api/v1/users_controller.rb +262 -0
  10. data/app/controllers/erp_tech_svcs/session_controller.rb +8 -5
  11. data/app/controllers/erp_tech_svcs/user_controller.rb +14 -15
  12. data/app/mailers/user_mailer.rb +8 -5
  13. data/app/models/audit_log.rb +111 -36
  14. data/app/models/audit_log_item.rb +30 -0
  15. data/app/models/audit_log_item_type.rb +1 -0
  16. data/app/models/audit_log_type.rb +19 -0
  17. data/app/models/capability.rb +22 -6
  18. data/app/models/extensions/tracked_status_type.rb +3 -0
  19. data/app/models/file_asset.rb +245 -20
  20. data/app/models/file_asset_holder.rb +20 -0
  21. data/app/models/group.rb +38 -25
  22. data/app/models/notification.rb +32 -13
  23. data/app/models/notification_type.rb +13 -0
  24. data/app/models/security_role.rb +17 -4
  25. data/app/models/user.rb +116 -29
  26. data/app/validators/password_strength_validator.rb +1 -1
  27. data/app/views/user_mailer/activation_needed_email.html.erb +293 -15
  28. data/app/views/user_mailer/reset_password_email.html.erb +268 -13
  29. data/config/initializers/logger.rb +19 -0
  30. data/config/initializers/sorcery.rb +2 -0
  31. data/config/initializers/wickedpdf.rb +4 -0
  32. data/config/routes.rb +64 -0
  33. data/db/data_migrations/20110802200222_schedule_delete_expired_sessions_job.rb +1 -5
  34. data/db/data_migrations/20150819140550_create_job_tracker_for_notification.rb +14 -0
  35. data/db/migrate/20080805000010_base_tech_services.rb +99 -39
  36. data/db/migrate/20150414151421_add_nested_set_columns_to_security_role.rb +13 -0
  37. data/db/migrate/20150609003216_update_user_for_sorcery.rb +11 -0
  38. data/db/migrate/20150819135108_add_custom_fields_to_notifications.rb +5 -0
  39. data/db/migrate/20160122155402_add_description_to_file_asset.rb +13 -0
  40. data/db/migrate/20160310163060_add_created_by_updated_by_to_erp_tech_svcs.rb +35 -0
  41. data/db/migrate/20160313161611_add_tenant_id_to_audit_log.rb +16 -0
  42. data/lib/erp_tech_svcs.rb +6 -10
  43. data/lib/erp_tech_svcs/config.rb +7 -2
  44. data/lib/erp_tech_svcs/delayed_jobs/delete_expired_sessions_job.rb +49 -0
  45. data/lib/erp_tech_svcs/delayed_jobs/notification_job.rb +50 -0
  46. data/lib/erp_tech_svcs/engine.rb +0 -1
  47. data/lib/erp_tech_svcs/erp_tech_svcs_audit_log.rb +12 -6
  48. data/lib/erp_tech_svcs/extensions.rb +0 -1
  49. data/lib/erp_tech_svcs/extensions/active_record/has_capability_accessors.rb +57 -29
  50. data/lib/erp_tech_svcs/extensions/active_record/has_file_assets.rb +57 -31
  51. data/lib/erp_tech_svcs/extensions/active_record/has_security_roles.rb +12 -4
  52. data/lib/erp_tech_svcs/extensions/active_record/is_json.rb +22 -15
  53. data/lib/erp_tech_svcs/extensions/active_record/scoped_by.rb +16 -13
  54. data/lib/erp_tech_svcs/extensions/compass_ae/erp_base_erp_svcs/controllers/api/parties_controller.rb +15 -0
  55. data/lib/erp_tech_svcs/file_support.rb +1 -0
  56. data/lib/erp_tech_svcs/file_support/file_system_manager.rb +77 -44
  57. data/lib/erp_tech_svcs/file_support/manager.rb +12 -3
  58. data/lib/erp_tech_svcs/file_support/railties/compass_ae_resolver.rb +49 -0
  59. data/lib/erp_tech_svcs/file_support/s3_manager.rb +73 -51
  60. data/lib/erp_tech_svcs/utils/compass_access_negotiator.rb +11 -2
  61. data/lib/erp_tech_svcs/utils/default_nested_set_methods.rb +238 -46
  62. data/lib/erp_tech_svcs/version.rb +1 -1
  63. data/lib/tasks/erp_tech_svcs_tasks.rake +43 -5
  64. metadata +73 -42
  65. data/app/models/user_defined_data.rb +0 -6
  66. data/app/models/user_defined_field.rb +0 -8
  67. data/config/initializers/pdfkit.rb +0 -18
  68. data/db/data_migrations/20121130212146_note_capabilities.rb +0 -23
  69. data/db/migrate/20121116151510_create_groups.rb +0 -18
  70. data/db/migrate/20121126171612_upgrade_security.rb +0 -53
  71. data/db/migrate/20121126173506_upgrade_security2.rb +0 -274
  72. data/db/migrate/20130410135419_add_queue_to_delayed_jobs.rb +0 -13
  73. data/db/migrate/20130610163240_create_notifications.rb +0 -37
  74. data/db/migrate/20130725212647_add_party_id_idx_to_users.rb +0 -9
  75. data/db/migrate/20131113213843_add_audit_log_item_old_value.rb +0 -13
  76. data/db/migrate/20131113213844_add_erp_tech_svcs_missing_indexes.rb +0 -31
  77. data/db/migrate/20131129203603_add_user_defined_fields.rb +0 -43
  78. data/db/migrate/20141013060204_add_custom_fields_to_notifications.rb +0 -12
  79. data/db/migrate/20141108182427_add_scoped_by_to_file_assets.rb +0 -14
  80. data/lib/erp_tech_svcs/extensions/active_record/has_user_defined_data.rb +0 -147
  81. data/lib/erp_tech_svcs/sessions/delete_expired_sessions_job.rb +0 -47
  82. data/lib/erp_tech_svcs/sessions/delete_expired_sessions_service.rb +0 -15
  83. data/lib/erp_tech_svcs/utils/compass_logger.rb +0 -87
@@ -0,0 +1,13 @@
1
+ class AddNestedSetColumnsToSecurityRole < ActiveRecord::Migration
2
+ def change
3
+ add_column :security_roles, :lft, :integer unless column_exists?(:security_roles, :lft)
4
+ add_column :security_roles, :rgt, :integer unless column_exists?(:security_roles, :rgt)
5
+ add_column :security_roles, :parent_id, :integer unless column_exists?(:security_roles, :parent_id)
6
+
7
+ add_index :security_roles, :parent_id unless index_exists?(:security_roles, :parent_id)
8
+ add_index :security_roles, :lft unless index_exists?(:security_roles, :lft)
9
+ add_index :security_roles, :rgt unless index_exists?(:security_roles, :rgt)
10
+
11
+ SecurityRole.rebuild!
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ class UpdateUserForSorcery < ActiveRecord::Migration
2
+ def up
3
+ add_column :users, :unlock_token, :string, :default => nil unless column_exists? :users, :unlock_token
4
+ add_column :users, :last_login_from_ip_address, :string, :default => nil unless column_exists? :users, :last_login_from_ip_address
5
+ end
6
+
7
+ def down
8
+ remove_column :users, :unlock_token
9
+ remove_column :users, :last_login_from_ip_address
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ class AddCustomFieldsToNotifications < ActiveRecord::Migration
2
+ def change
3
+ add_column :notifications, :custom_fields, :text unless column_exists?(:notifications, :custom_fields)
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ class AddDescriptionToFileAsset < ActiveRecord::Migration
2
+ def up
3
+ unless column_exists? :file_assets, :description
4
+ add_column :file_assets, :description, :string
5
+ end
6
+ end
7
+
8
+ def down
9
+ if column_exists? :file_assets, :description
10
+ remove_column :file_assets, :description
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,35 @@
1
+ class AddCreatedByUpdatedByToErpTechSvcs < ActiveRecord::Migration
2
+ def up
3
+ %w{file_assets}.each do |table|
4
+
5
+ unless column_exists? table.to_sym, :created_by_party_id
6
+ add_column table.to_sym, :created_by_party_id, :integer
7
+
8
+ add_index table.to_sym, :created_by_party_id, name: "#{table}_created_by_pty_idx"
9
+ end
10
+
11
+ unless column_exists? table.to_sym, :updated_by_party_id
12
+ add_column table.to_sym, :updated_by_party_id, :integer
13
+
14
+ add_index table.to_sym, :updated_by_party_id, name: "#{table}_updated_by_pty_idx"
15
+ end
16
+
17
+ end
18
+
19
+ end
20
+
21
+ def down
22
+ %w{file_assets}.each do |table|
23
+
24
+ if column_exists? table.to_sym, :created_by_party_id
25
+ remove_column table.to_sym, :created_by_party_id
26
+ end
27
+
28
+ if column_exists? table.to_sym, :updated_by_party_id
29
+ remove_column table.to_sym, :updated_by_party_id
30
+ end
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -0,0 +1,16 @@
1
+ class AddTenantIdToAuditLog < ActiveRecord::Migration
2
+ def up
3
+ unless column_exists? :audit_logs, :tenant_id
4
+ add_column :audit_logs, :tenant_id, :integer
5
+
6
+ add_index :audit_logs, :tenant_id, name: 'audit_logs_tenant_id'
7
+ end
8
+ end
9
+
10
+ def down
11
+ if column_exists? :audit_log, :tenant_id
12
+ remove_column :audit_logs, :tenant_id
13
+ end
14
+ end
15
+
16
+ end
@@ -1,19 +1,14 @@
1
- require 'aasm'
2
-
3
- #compass_ae libraries
4
1
  require 'erp_base_erp_svcs'
5
-
2
+ require 'aasm'
6
3
  require 'paperclip'
7
4
  require 'delayed_job'
8
5
  require 'delayed_job_active_record'
9
6
  require 'mail_alternatives_with_attachments'
10
7
  require 'sorcery'
11
- require 'pdfkit'
12
- require 'aws'
13
- require 'activerecord-postgres-hstore'
8
+ require 'wicked_pdf'
9
+ require 'aws-sdk'
14
10
  require 'nested-hstore'
15
11
  require "erp_tech_svcs/version"
16
- require "erp_tech_svcs/utils/compass_logger"
17
12
  require "erp_tech_svcs/utils/default_nested_set_methods"
18
13
  require "erp_tech_svcs/utils/compass_access_negotiator"
19
14
  require "erp_tech_svcs/extensions"
@@ -21,8 +16,9 @@ require 'erp_tech_svcs/file_support'
21
16
  require 'erp_tech_svcs/sms_wrapper'
22
17
  require "erp_tech_svcs/config"
23
18
  require "erp_tech_svcs/engine"
24
- require 'erp_tech_svcs/sessions/delete_expired_sessions_job'
25
- require 'erp_tech_svcs/sessions/delete_expired_sessions_service'
26
19
  require 'erp_tech_svcs/erp_tech_svcs_audit_log'
20
+ require 'erp_tech_svcs/delayed_jobs/notification_job'
21
+ require 'erp_tech_svcs/delayed_jobs/delete_expired_sessions_job'
22
+
27
23
  module ErpTechSvcs
28
24
  end
@@ -16,7 +16,7 @@ module ErpTechSvcs
16
16
  :file_storage,
17
17
  :s3_cache_expires_in_minutes,
18
18
  :session_expires_in_hours,
19
- :compass_logger_path
19
+ :notification_job_delay
20
20
 
21
21
  def init!
22
22
  @defaults = {
@@ -33,7 +33,7 @@ module ErpTechSvcs
33
33
  :@s3_protocol => 'https', # Can be either 'http' or 'https'
34
34
  :@file_storage => :filesystem, # Can be either :s3 or :filesystem
35
35
  :@session_expires_in_hours => 12, # this is used by DeleteExpiredSessionsJob to purge inactive sessions from database
36
- :@compass_logger_path => "#{Rails.root}/log"
36
+ :@notification_job_delay => '2 minutes from now'
37
37
  }
38
38
  end
39
39
 
@@ -50,6 +50,11 @@ module ErpTechSvcs
50
50
  def configure!
51
51
  @configure_blk.call(self) if @configure_blk
52
52
  end
53
+
54
+ def installation_url
55
+ "#{self.file_protocol}://#{self.installation_domain}"
56
+ end
57
+
53
58
  end
54
59
  init!
55
60
  reset!
@@ -0,0 +1,49 @@
1
+ require "benchmark"
2
+
3
+ module ErpTechSvcs
4
+ module DelayedJobs
5
+ # Delayed Job to Reset Daily Assignments to Forecast
6
+ class DeleteExpiredSessionsJob
7
+
8
+ def initialize
9
+ @priority = 1
10
+ end
11
+
12
+ def perform
13
+ unless Dir.exists?(File.join(Rails.root, 'log/delayed_jobs'))
14
+ Dir.mkdir(File.join(Rails.root, 'log/delayed_jobs'))
15
+ end
16
+
17
+ logger = Logger.new(File.join(Rails.root,"log/delayed_jobs/#{Rails.env}-delete_expired_sessions_job.log"), "weekly")
18
+ logger.level = Logger::INFO
19
+
20
+ time = Benchmark.measure do
21
+ begin
22
+ ActiveRecord::SessionStore::Session.delete_all ['updated_at < ?', ErpTechSvcs::Config.session_expires_in_hours.hours.ago]
23
+ rescue => ex
24
+ logger.error("#{Time.now}**************************************************")
25
+ logger.error("Job Error: #{ex.message}")
26
+ logger.error("Trace: #{ex.backtrace.join("\n")}")
27
+ logger.error("*************************************************************")
28
+
29
+ # email notification
30
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
31
+ end
32
+ end #benchmark
33
+
34
+ # Run once per day
35
+ start_time = Time.now + 1.day
36
+
37
+ Delayed::Job.enqueue(DeleteExpiredSessionsJob.new, @priority, start_time)
38
+
39
+ # Update job tracker
40
+ JobTracker.job_ran('Delete Expired Sessions', self.class.name, ("(%.4fs)" % time.real), start_time)
41
+ end
42
+
43
+ def self.schedule_job(schedule_dt)
44
+ Delayed::Job.enqueue(DeleteExpiredSessionsJob.new, @priority, schedule_dt)
45
+ end
46
+
47
+ end # DeleteExpiredSessionsJob
48
+ end # DelayedJobs
49
+ end # ErpTechSvcs
@@ -0,0 +1,50 @@
1
+ require 'benchmark'
2
+ require 'chronic'
3
+
4
+ module ErpTechSvcs
5
+ module DelayedJobs
6
+ class NotificationJob
7
+
8
+ def initialize
9
+ @priority = 1
10
+ end
11
+
12
+ def perform
13
+ unless Dir.exists?(File.join(Rails.root, 'log/delayed_jobs'))
14
+ Dir.mkdir(File.join(Rails.root, 'log/delayed_jobs'))
15
+ end
16
+
17
+ logger = Logger.new(File.join(Rails.root,"log/delayed_jobs/#{Rails.env}-notifications_job.log"), "weekly")
18
+ logger.level = Logger::INFO
19
+
20
+ time = Benchmark.measure do
21
+ begin
22
+ Notification.where('current_state = ?', 'pending').each do |notification|
23
+ notification.deliver_notification
24
+ end
25
+
26
+ rescue Exception => ex
27
+ logger.error("#{Time.now}**************************************************")
28
+ logger.error("Job Error: #{ex.message}")
29
+ logger.error("Trace: #{ex.backtrace.join("\n")}")
30
+ logger.error("*************************************************************")
31
+
32
+ # email notification
33
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
34
+ end
35
+ end
36
+
37
+ start_time = Chronic.parse(ErpTechSvcs::Config.notification_job_delay)
38
+ Delayed::Job.enqueue(ErpTechSvcs::DelayedJobs::NotificationJob.new, @priority, start_time)
39
+
40
+ #update job tracker
41
+ JobTracker.job_ran('Notification Job', self.class.name, ("(%.4fs)" % time.real), start_time)
42
+ end
43
+
44
+ def self.schedule_job(schedule_at)
45
+ Delayed::Job.enqueue(ErpTechSvcs::DelayedJobs::NotificationJob.new, @priority, schedule_at)
46
+ end
47
+
48
+ end # NotificationJob
49
+ end # DelayedJobs
50
+ end # ErpTechSvcs
@@ -9,7 +9,6 @@ module ErpTechSvcs
9
9
  include ErpTechSvcs::Extensions::ActiveRecord::HasFileAssets
10
10
  include ErpTechSvcs::Extensions::ActiveRecord::ProtectedByCapabilities
11
11
  include ErpTechSvcs::Extensions::ActiveRecord::HasCapabilityAccessors
12
- include ErpTechSvcs::Extensions::ActiveRecord::HasUserDefinedData
13
12
  include ErpTechSvcs::Extensions::ActiveRecord::IsJson
14
13
  include ErpTechSvcs::Extensions::ActiveRecord::ScopedBy
15
14
  end
@@ -3,23 +3,29 @@ module ErpTechSvcs
3
3
  class << self
4
4
 
5
5
  #log when a user logs out
6
- def successful_logout(user_id)
7
- user = User.find(user_id)
8
- AuditLog.create(
6
+ def successful_logout(user)
7
+
8
+ if user.is_a? Integer
9
+ user = User.find(user)
10
+ end
11
+
12
+ AuditLog.create!(
9
13
  :party_id => user.party.id,
10
14
  :event_record => user,
11
15
  :audit_log_type => AuditLogType.find_by_type_and_subtype_iid('application','successful_logout'),
12
- :description => "User #{user.username} successfully logged out."
16
+ :description => "User #{user.username} successfully logged out.",
17
+ :tenant_id => user.party.dba_organization.id
13
18
  )
14
19
  end
15
20
 
16
21
  #log when a user logs out
17
22
  def successful_login(user)
18
- AuditLog.create(
23
+ AuditLog.create!(
19
24
  :party_id => user.party.id,
20
25
  :event_record => user,
21
26
  :audit_log_type => AuditLogType.find_by_type_and_subtype_iid('application','successful_login'),
22
- :description => "User #{user.username} successfully logged in."
27
+ :description => "User #{user.username} successfully logged in.",
28
+ :tenant_id => user.party.dba_organization.id
23
29
  )
24
30
  end
25
31
 
@@ -8,7 +8,6 @@ require 'erp_tech_svcs/extensions/active_record/has_security_roles'
8
8
  require 'erp_tech_svcs/extensions/active_record/protected_with_capabilities'
9
9
  require 'erp_tech_svcs/extensions/active_record/has_capability_accessors'
10
10
  require 'erp_tech_svcs/extensions/active_record/acts_as_versioned'
11
- require 'erp_tech_svcs/extensions/active_record/has_user_defined_data'
12
11
  require 'erp_tech_svcs/extensions/active_record/is_json'
13
12
  require 'erp_tech_svcs/extensions/active_record/scoped_by'
14
13
 
@@ -12,23 +12,21 @@ module ErpTechSvcs
12
12
  def has_capability_accessors
13
13
  extend HasCapabilityAccessors::SingletonMethods
14
14
  include HasCapabilityAccessors::InstanceMethods
15
-
15
+
16
16
  has_many :capability_accessors, :as => :capability_accessor_record
17
17
  end
18
-
19
18
  end
20
-
19
+
21
20
  module SingletonMethods
22
-
23
21
  end
24
22
 
25
- module InstanceMethods
23
+ module InstanceMethods
26
24
 
27
25
  # method to get capabilities this instance does NOT have
28
26
  def capabilities_not
29
27
  Capability.joins(:capability_type).
30
- joins("LEFT JOIN capability_accessors ON capability_accessors.capability_id = capabilities.id AND capability_accessors.capability_accessor_record_type = '#{self.class.name}' AND capability_accessors.capability_accessor_record_id = #{self.id}").
31
- where("capability_accessors.id IS NULL")
28
+ joins("LEFT JOIN capability_accessors ON capability_accessors.capability_id = capabilities.id AND capability_accessors.capability_accessor_record_type = '#{self.class.name}' AND capability_accessors.capability_accessor_record_id = #{self.id}").
29
+ where("capability_accessors.id IS NULL")
32
30
  end
33
31
 
34
32
  def scope_capabilities_not(scope_type_iid)
@@ -47,7 +45,7 @@ module ErpTechSvcs
47
45
 
48
46
  def capabilities
49
47
  Capability.joins(:capability_type).joins(:capability_accessors).
50
- where(:capability_accessors => { :capability_accessor_record_type => self.class.name, :capability_accessor_record_id => self.id })
48
+ where(:capability_accessors => { :capability_accessor_record_type => self.class.name, :capability_accessor_record_id => self.id })
51
49
  end
52
50
 
53
51
  def scope_capabilities(scope_type_iid)
@@ -75,19 +73,6 @@ module ErpTechSvcs
75
73
  scope_capabilities('instance')
76
74
  end
77
75
 
78
- # pass in (capability_type_iid, klass) or (capability) object
79
- def add_capability(*capability)
80
- capability_type_iid = capability.first.is_a?(Symbol) ? capability.first.to_s : capability.first
81
- capability = capability_type_iid.is_a?(String) ? get_or_create_capability(capability_type_iid, capability.second) : capability.first
82
- ca = CapabilityAccessor.find_or_create_by_capability_accessor_record_type_and_capability_accessor_record_id_and_capability_id(get_superclass, self.id, capability.id)
83
- self.reload
84
- ca
85
- end
86
-
87
- def grant_capability(*capability)
88
- add_capability(*capability)
89
- end
90
-
91
76
  def get_or_create_capability(capability_type_iid, klass)
92
77
  capability_type = convert_capability_type(capability_type_iid)
93
78
  if klass.is_a?(String)
@@ -104,6 +89,32 @@ module ErpTechSvcs
104
89
  Capability.find_by_capability_resource_type_and_capability_type_id_and_scope_type_id(klass, capability_type.id, scope_type.id)
105
90
  end
106
91
 
92
+ def has_capabilities?
93
+ !capability_accessors.empty?
94
+ end
95
+
96
+ # Add multiple capabilities
97
+ #
98
+ # @param _capabilities [Array] Array of Capbilities
99
+ def add_capabilities(_capabilities)
100
+ _capabilities.each do |capability|
101
+ add_capability(capability)
102
+ end
103
+ end
104
+
105
+ alias :grant_capabilities :add_capabilities
106
+
107
+ # pass in (capability_type_iid, klass) or (capability) object
108
+ def add_capability(*capability)
109
+ capability_type_iid = capability.first.is_a?(Symbol) ? capability.first.to_s : capability.first
110
+ capability = capability_type_iid.is_a?(String) ? get_or_create_capability(capability_type_iid, capability.second) : capability.first
111
+ ca = CapabilityAccessor.find_or_create_by_capability_accessor_record_type_and_capability_accessor_record_id_and_capability_id(get_superclass, self.id, capability.id)
112
+ self.reload
113
+ ca
114
+ end
115
+
116
+ alias :grant_capability :add_capability
117
+
107
118
  # pass in (capability_type_iid, klass) or (capability) object
108
119
  def remove_capability(*capability)
109
120
  capability_type_iid = capability.first.is_a?(Symbol) ? capability.first.to_s : capability.first
@@ -114,15 +125,31 @@ module ErpTechSvcs
114
125
  ca
115
126
  end
116
127
 
117
- def revoke_capability(*capability)
118
- remove_capability(*capability)
128
+ alias :revoke_capability :remove_capability
129
+
130
+ # Remove multiple capabilities
131
+ #
132
+ # @param _capabilities [Array] Array of Capbilities
133
+ def remove_capabilities(_capabilities)
134
+ _capabilities.each do |capability|
135
+ remove_capability(capability)
136
+ end
119
137
  end
120
138
 
121
- def has_capabilities?
122
- !capability_accessors.empty?
139
+ alias :revoke_capabilities :remove_capabilities
140
+
141
+ # Remove all current capabilities
142
+ #
143
+ def remove_all_capabilities
144
+ capabilities.each do |capability|
145
+ remove_capability(capability)
146
+ end
123
147
  end
124
148
 
149
+ alias :revoke_all_capabilities :remove_all_capabilities
150
+
125
151
  private
152
+
126
153
  def convert_capability_type(type)
127
154
  return type if type.is_a?(CapabilityType)
128
155
  return nil unless (type.is_a?(String) || type.is_a?(Symbol))
@@ -131,7 +158,8 @@ module ErpTechSvcs
131
158
  CapabilityType.create(:internal_identifier => type.to_s, :description => type.to_s.titleize)
132
159
  end
133
160
  end
134
- end
135
- end
136
- end
137
- end
161
+
162
+ end # HasCapabilityAccessors
163
+ end # ActiveRecord
164
+ end # Extensions
165
+ end # ErpTechSvcs