Module: Legion::Identity::Trust
- Defined in:
- lib/legion/identity/trust.rb
Constant Summary collapse
- LEVELS =
%i[verified authenticated configured cached unverified].freeze
- RANK =
LEVELS.each_with_index.to_h.freeze
Class Method Summary collapse
- .above?(level_a, level_b) ⇒ Boolean
- .at_least?(level, minimum) ⇒ Boolean
- .levels ⇒ Object
- .rank(level) ⇒ Object
Class Method Details
.above?(level_a, level_b) ⇒ Boolean
19 20 21 22 23 24 25 |
# File 'lib/legion/identity/trust.rb', line 19 def above?(level_a, level_b) rank_a = RANK[level_a] rank_b = RANK[level_b] return false if rank_a.nil? || rank_b.nil? rank_a < rank_b end |
.at_least?(level, minimum) ⇒ Boolean
27 28 29 30 31 32 33 |
# File 'lib/legion/identity/trust.rb', line 27 def at_least?(level, minimum) rank_level = RANK[level] rank_min = RANK[minimum] return false if rank_level.nil? || rank_min.nil? rank_level <= rank_min end |
.levels ⇒ Object
11 12 13 |
# File 'lib/legion/identity/trust.rb', line 11 def levels LEVELS end |
.rank(level) ⇒ Object
15 16 17 |
# File 'lib/legion/identity/trust.rb', line 15 def rank(level) RANK[level] end |