Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/account_scopper.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

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, options = {})
  if Account. != nil && column_names.include?("account_id")
    with_scope(:find => {:conditions => ["account_id = ?", Account..id]}) do
      orig_calculate(operation, column_name, options)
    end
  else
    orig_calculate(operation, column_name, options)
  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. != nil && column_names.include?("account_id")
    with_scope(:find => {:conditions => "account_id = "+Account..id.to_s}) do
      orig_delete_all(conditions)
    end
  else
    orig_delete_all(conditions)
  end
end

.orig_calculateObject



15
# File 'lib/account_scopper.rb', line 15

alias_method :orig_calculate, :calculate

.orig_delete_allObject



4
# File 'lib/account_scopper.rb', line 4

alias_method :orig_delete_all, :delete_all

Instance Method Details

#destroyObject



41
42
43
44
45
46
47
# File 'lib/account_scopper.rb', line 41

def destroy
  if !Account..nil? && respond_to?(:account_id)
    orig_destroy if self. == Account..id
  else
    orig_destroy
  end
end

#orig_destroyObject

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