Module: Consent::SubjectCoder
- Defined in:
- lib/consent/subject_coder.rb
Overview
Coder for ability subjects
Defined Under Namespace
Modules: Model
Class Method Summary collapse
-
.dump(key) ⇒ String
Dumps a serialized key (snake case string) from a valid permission subject (a constant or a symbol).
-
.load(key) ⇒ Module, ...
Loads the serialized key (snake case string) as a valid permission subject (a constant or a symbol).
Class Method Details
.dump(key) ⇒ String
Dumps a serialized key (snake case string) from a valid permission subject (a constant or a symbol)
35 36 37 |
# File 'lib/consent/subject_coder.rb', line 35 def dump(key) key.to_s.underscore end |
.load(key) ⇒ Module, ...
Loads the serialized key (snake case string) as a valid permission subject (a constant or a symbol)
23 24 25 26 27 28 |
# File 'lib/consent/subject_coder.rb', line 23 def load(key) return nil unless key constant = key.camelize.safe_constantize constant.is_a?(Class) ? constant : key.to_sym end |