Module: Consent::SubjectCoder
- Defined in:
- lib/consent/subject_coder.rb
Overview
Coder for ability subjects
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)
25 26 27 |
# File 'lib/consent/subject_coder.rb', line 25 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)
13 14 15 16 17 18 |
# File 'lib/consent/subject_coder.rb', line 13 def load(key) return nil unless key constant = key.camelize.safe_constantize constant.is_a?(Class) ? constant : key.to_sym end |