bhm-admin 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bhm-admin.gemspec +2 -2
- data/lib/bhm/admin/attr_accessible_scoping.rb +26 -6
- data/lib/bhm/admin.rb +5 -1
- metadata +4 -4
data/bhm-admin.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bhm-admin}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Darcy Laycock"]
|
12
|
-
s.date = %q{2010-12-
|
12
|
+
s.date = %q{2010-12-14}
|
13
13
|
s.description = %q{Provides a reasonably dynamic and simple to use admin area for Rails 3 application. Built on a bunch of open source libraries.}
|
14
14
|
s.email = %q{sutto@sutto.net}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -4,8 +4,18 @@ module BHM
|
|
4
4
|
UnassignableAttribute = Class.new(StandardError)
|
5
5
|
|
6
6
|
class << self
|
7
|
+
|
8
|
+
def verbose?
|
9
|
+
!Thread.current[:attr_accessible_silent]
|
10
|
+
end
|
11
|
+
|
12
|
+
def silent!
|
13
|
+
Thread.current[:attr_accessible_silent] = true
|
14
|
+
end
|
7
15
|
|
8
|
-
|
16
|
+
def verbose!
|
17
|
+
Thread.current[:attr_accessible_silent] = nil
|
18
|
+
end
|
9
19
|
|
10
20
|
def disabled?
|
11
21
|
!enabled?
|
@@ -24,11 +34,19 @@ module BHM
|
|
24
34
|
end
|
25
35
|
|
26
36
|
def disable
|
27
|
-
|
28
|
-
|
37
|
+
enabled = !disabled?
|
38
|
+
enable! if enabled
|
29
39
|
yield if block_given?
|
30
40
|
ensure
|
31
|
-
enable! if
|
41
|
+
enable! if enabled
|
42
|
+
end
|
43
|
+
|
44
|
+
def silence
|
45
|
+
verbose = verbose?
|
46
|
+
silent! if verbose
|
47
|
+
yield if block_given?
|
48
|
+
ensure
|
49
|
+
verbose! if verbose
|
32
50
|
end
|
33
51
|
|
34
52
|
end
|
@@ -36,7 +54,7 @@ module BHM
|
|
36
54
|
class Sanitizer < ActiveModel::MassAssignmentSecurity::WhiteList
|
37
55
|
|
38
56
|
def deny?(attribute)
|
39
|
-
return false if
|
57
|
+
return false if AttrAccessibleScoping.disabled? || self.include?("all")
|
40
58
|
super
|
41
59
|
end
|
42
60
|
|
@@ -44,7 +62,9 @@ module BHM
|
|
44
62
|
|
45
63
|
def warn!(attrs)
|
46
64
|
super
|
47
|
-
|
65
|
+
if AttrAccessibleScoping.verbose?
|
66
|
+
raise UnassignableAttribute.new("Unable to assign attributes: #{attrs.join(", ")}")
|
67
|
+
end
|
48
68
|
end
|
49
69
|
|
50
70
|
end
|
data/lib/bhm/admin.rb
CHANGED
@@ -3,7 +3,7 @@ require 'active_support'
|
|
3
3
|
module BHM
|
4
4
|
module Admin
|
5
5
|
|
6
|
-
VERSION = "0.
|
6
|
+
VERSION = "0.3.0".freeze
|
7
7
|
|
8
8
|
# Helpers for use in the admin area.
|
9
9
|
autoload :SidebarHelper, 'bhm/admin/sidebar_helper'
|
@@ -33,6 +33,10 @@ module BHM
|
|
33
33
|
def self.disable_attr_accessible(&blk)
|
34
34
|
AttrAccessibleScoping.disable(&blk)
|
35
35
|
end
|
36
|
+
|
37
|
+
def self.silence_attr_accessible(&blk)
|
38
|
+
AttrAccessibleScoping.silence(&blk)
|
39
|
+
end
|
36
40
|
|
37
41
|
def self.disable_attr_accessible!
|
38
42
|
AttrAccessibleScoping.disable!
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bhm-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 2
|
9
8
|
- 3
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Darcy Laycock
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-12-
|
18
|
+
date: 2010-12-14 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|