Class: Karst::Access::PopulationRevocation
- Inherits:
-
Object
- Object
- Karst::Access::PopulationRevocation
- Defined in:
- lib/karst/access/population_revocation.rb
Overview
Removes one exact, already-stored approval while preserving every other entry. Submitted values can never add or alter an approval.
Constant Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(submitted:, record: PopulationApprovals.load) ⇒ PopulationRevocation
constructor
A new instance of PopulationRevocation.
Constructor Details
#initialize(submitted:, record: PopulationApprovals.load) ⇒ PopulationRevocation
Returns a new instance of PopulationRevocation.
14 15 16 17 |
# File 'lib/karst/access/population_revocation.rb', line 14 def initialize(submitted:, record: PopulationApprovals.load) @submitted = submitted.to_s @record = record end |
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/karst/access/population_revocation.rb', line 19 def call entry = @record.entries.find { |candidate| key(candidate) == @submitted } return Result.new(record: @record, revoked: false) unless entry record = PopulationApprovals.replace(@record.entries - [entry]) Result.new(record: record, revoked: record.error.nil?) end |