Class: ActiveRecord::Extensions::ForeignKeys::ForeignKeyController

Inherits:
Object
  • Object
show all
Defined in:
lib/ar-extensions/foreign_keys.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(clazz) ⇒ ForeignKeyController

Returns a new instance of ForeignKeyController.



38
39
40
# File 'lib/ar-extensions/foreign_keys.rb', line 38

def initialize( clazz )
  @clazz = clazz
end

Instance Attribute Details

#clazzObject (readonly)

Returns the value of attribute clazz.



36
37
38
# File 'lib/ar-extensions/foreign_keys.rb', line 36

def clazz
  @clazz
end

Instance Method Details

#disableObject

:nodoc:



42
43
44
45
46
47
48
49
50
# File 'lib/ar-extensions/foreign_keys.rb', line 42

def disable # :nodoc:
  if block_given?
    disable
    yield
    enable
  else
    clazz.connection.execute "set foreign_key_checks = 0"
  end
end

#enableObject

:nodoc:



52
53
54
55
56
57
58
59
60
# File 'lib/ar-extensions/foreign_keys.rb', line 52

def enable #:nodoc:
  if block_given?
    enable
    yield
    disable
  else
    clazz.connection.execute "set foreign_key_checks = 1"
  end
end