Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/account_scopper.rb
Overview
:nodoc:
Class Method Summary collapse
- .calculate(operation, column_name, options = {}) ⇒ Object
- .delete_all(conditions = nil) ⇒ Object
- .orig_calculate ⇒ Object
- .orig_delete_all ⇒ Object
Instance Method Summary collapse
- #destroy ⇒ Object
-
#orig_destroy ⇒ Object
Instance methods, they are called from an instance of a model (an object).
Class Method Details
.calculate(operation, column_name, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/account_scopper.rb', line 16 def calculate(operation, column_name, = {}) if Account.current_account != nil && column_names.include?("account_id") with_scope(:find => {:conditions => ["account_id = ?", Account.current_account.id]}) do orig_calculate(operation, column_name, ) end else orig_calculate(operation, column_name, ) end end |
.delete_all(conditions = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/account_scopper.rb', line 5 def delete_all(conditions = nil) if Account.current_account != nil && column_names.include?("account_id") with_scope(:find => {:conditions => "account_id = "+Account.current_account.id.to_s}) do orig_delete_all(conditions) end else orig_delete_all(conditions) end end |
.orig_calculate ⇒ Object
15 |
# File 'lib/account_scopper.rb', line 15 alias_method :orig_calculate, :calculate |
.orig_delete_all ⇒ Object
4 |
# File 'lib/account_scopper.rb', line 4 alias_method :orig_delete_all, :delete_all |
Instance Method Details
#destroy ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/account_scopper.rb', line 41 def destroy if !Account.current_account.nil? && respond_to?(:account_id) orig_destroy if self.account_id == Account.current_account.id else orig_destroy end end |
#orig_destroy ⇒ Object
Instance methods, they are called from an instance of a model (an object)
40 |
# File 'lib/account_scopper.rb', line 40 alias_method :orig_destroy, :destroy |