Module: BHM::Admin::AttrAccessibleScoping

Defined in:
lib/bhm/admin/attr_accessible_scoping.rb

Defined Under Namespace

Modules: ARMixin Classes: Sanitizer

Constant Summary collapse

UnassignableAttribute =
Class.new(StandardError)

Class Method Summary collapse

Class Method Details

.disableObject



36
37
38
39
40
41
42
# File 'lib/bhm/admin/attr_accessible_scoping.rb', line 36

def disable
  enabled = !disabled?
  enable! if enabled
  yield if block_given?
ensure
  enable! if enabled
end

.disable!Object



28
29
30
# File 'lib/bhm/admin/attr_accessible_scoping.rb', line 28

def disable!
  Thread.current[:attr_accessible_disabled] = true
end

.disabled?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/bhm/admin/attr_accessible_scoping.rb', line 20

def disabled?
  !enabled?
end

.enable!Object



32
33
34
# File 'lib/bhm/admin/attr_accessible_scoping.rb', line 32

def enable!
  Thread.current[:attr_accessible_disabled] = nil
end

.enabled?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/bhm/admin/attr_accessible_scoping.rb', line 24

def enabled?
  !Thread.current[:attr_accessible_disabled]
end

.silenceObject



44
45
46
47
48
49
50
# File 'lib/bhm/admin/attr_accessible_scoping.rb', line 44

def silence
  verbose = verbose?
  silent! if verbose
  yield if block_given?
ensure
  verbose! if verbose
end

.silent!Object



12
13
14
# File 'lib/bhm/admin/attr_accessible_scoping.rb', line 12

def silent!
  Thread.current[:attr_accessible_silent] = true
end

.verbose!Object



16
17
18
# File 'lib/bhm/admin/attr_accessible_scoping.rb', line 16

def verbose!
  Thread.current[:attr_accessible_silent] = nil
end

.verbose?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/bhm/admin/attr_accessible_scoping.rb', line 8

def verbose?
  !Thread.current[:attr_accessible_silent]
end