active_record_disabler 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +22 -0
- data/lib/active_record_disabler.rb +18 -0
- metadata +96 -0
data/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
## Active Record Disabler
|
2
|
+
|
3
|
+
Allow / disallow query execution through active record
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
ActiveRecord.disable
|
9
|
+
|
10
|
+
User.first
|
11
|
+
# ActiveRecordDisabledError: Active Record is disabled
|
12
|
+
|
13
|
+
ActiveRecord.enable
|
14
|
+
|
15
|
+
User.first
|
16
|
+
#=> #<User id: 1, name: "John Smith">
|
17
|
+
|
18
|
+
ActiveRecord.disable "Can't touch this"
|
19
|
+
|
20
|
+
User.first
|
21
|
+
# ActiveRecordDisabledError: Can't touch this
|
22
|
+
```
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "active_record"
|
2
|
+
|
3
|
+
class ActiveRecordDisabledError < StandardError; end
|
4
|
+
|
5
|
+
module ActiveRecord
|
6
|
+
class << self
|
7
|
+
def enable
|
8
|
+
Relation.send(:alias_method, :exec_queries, :ar_enabled)
|
9
|
+
end
|
10
|
+
|
11
|
+
def disable(message = "Active Record is disabled")
|
12
|
+
Relation.send(:alias_method, :ar_enabled, :exec_queries)
|
13
|
+
Relation.send(:define_method, :ar_disabled) { raise ActiveRecordDisabledError, message }
|
14
|
+
|
15
|
+
Relation.send(:alias_method, :exec_queries, :ar_disabled)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_record_disabler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chris Patuzzo
|
9
|
+
- Nick Street
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-09-12 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activerecord
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: rspec
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sqlite3
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
description: Allow / disallow query execution through active record
|
64
|
+
email: developers@reevoo.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- README.md
|
70
|
+
- lib/active_record_disabler.rb
|
71
|
+
homepage: https://github.com/reevoo/active_record_disabler
|
72
|
+
licenses: []
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 1.8.25
|
92
|
+
signing_key:
|
93
|
+
specification_version: 3
|
94
|
+
summary: Active Record Disabler
|
95
|
+
test_files: []
|
96
|
+
has_rdoc:
|