Module: ScopedAttrAccessible::ActiveModelMixin::ClassMethods
- Defined in:
- lib/scoped_attr_accessible/active_model_mixin.rb
Instance Method Summary collapse
- #attr_accessible(*args) ⇒ Object
- #attr_protected(*args) ⇒ Object
- #current_sanitizer_scope ⇒ Object
- #current_sanitizer_scope=(value) ⇒ Object
- #sanitizer_scope_converter(&converter) ⇒ Object
- #sanitizer_scope_recognizer(name, &recognizer) ⇒ Object
- #scoped_attr_sanitizer ⇒ Object
- #with_sanitizer_scope(scope_name) ⇒ Object
Instance Method Details
#attr_accessible(*args) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/scoped_attr_accessible/active_model_mixin.rb', line 23 def attr_accessible(*args) scopes = scopes_from_args(args) sanitizer = self.scoped_attr_sanitizer args.each do |attribute| scopes.each { |s| sanitizer.make_accessible attribute, s } end self. = sanitizer end |
#attr_protected(*args) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/scoped_attr_accessible/active_model_mixin.rb', line 32 def attr_protected(*args) scopes = scopes_from_args(args) sanitizer = self.scoped_attr_sanitizer args.each do |attribute| scopes.each { |s| sanitizer.make_protected attribute, s } end self. = sanitizer end |
#current_sanitizer_scope ⇒ Object
45 46 47 |
# File 'lib/scoped_attr_accessible/active_model_mixin.rb', line 45 def current_sanitizer_scope Thread.current[current_sanitizer_scope_key] end |
#current_sanitizer_scope=(value) ⇒ Object
49 50 51 |
# File 'lib/scoped_attr_accessible/active_model_mixin.rb', line 49 def current_sanitizer_scope=(value) Thread.current[current_sanitizer_scope_key] = value end |
#sanitizer_scope_converter(&converter) ⇒ Object
65 66 67 |
# File 'lib/scoped_attr_accessible/active_model_mixin.rb', line 65 def sanitizer_scope_converter(&converter) scoped_attr_sanitizer.define_converter(&converter) end |
#sanitizer_scope_recognizer(name, &recognizer) ⇒ Object
61 62 63 |
# File 'lib/scoped_attr_accessible/active_model_mixin.rb', line 61 def sanitizer_scope_recognizer(name, &recognizer) scoped_attr_sanitizer.define_recognizer(name, &recognizer) end |
#scoped_attr_sanitizer ⇒ Object
41 42 43 |
# File 'lib/scoped_attr_accessible/active_model_mixin.rb', line 41 def scoped_attr_sanitizer self._scoped_attr_sanitizer ||= ScopedAttrAccessible::Sanitizer.new end |
#with_sanitizer_scope(scope_name) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/scoped_attr_accessible/active_model_mixin.rb', line 53 def with_sanitizer_scope(scope_name) old_scope = current_sanitizer_scope self.current_sanitizer_scope = scope_name yield if block_given? ensure self.current_sanitizer_scope = old_scope end |