Class: ActiveRecord::Extensions::ForeignKeys::ForeignKeyController
- Inherits:
-
Object
- Object
- ActiveRecord::Extensions::ForeignKeys::ForeignKeyController
- Defined in:
- lib/ar-extensions/foreign_keys.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#clazz ⇒ Object
readonly
Returns the value of attribute clazz.
Instance Method Summary collapse
-
#disable ⇒ Object
:nodoc:.
-
#enable ⇒ Object
:nodoc:.
-
#initialize(clazz) ⇒ ForeignKeyController
constructor
A new instance of ForeignKeyController.
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
#clazz ⇒ Object (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
#disable ⇒ Object
: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 |
#enable ⇒ Object
: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 |