Class: Karst::Access::PopulationApproval
- Inherits:
-
Object
- Object
- Karst::Access::PopulationApproval
- Defined in:
- lib/karst/access/population_approval.rb
Overview
Adds explicitly selected candidates from one current discovery pass to the local approval record. Submitted values are treated only as keys: the Entry objects written below always come from discovery itself.
Constant Summary collapse
- Result =
Value.define(:record, :error) do def saved? error.nil? && record.error.nil? end end
- SEPARATOR =
"::"
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(discovery:, principal_sources:, submitted:, record: PopulationApprovals.load) ⇒ PopulationApproval
constructor
A new instance of PopulationApproval.
Constructor Details
#initialize(discovery:, principal_sources:, submitted:, record: PopulationApprovals.load) ⇒ PopulationApproval
Returns a new instance of PopulationApproval.
19 20 21 22 23 24 |
# File 'lib/karst/access/population_approval.rb', line 19 def initialize(discovery:, principal_sources:, submitted:, record: PopulationApprovals.load) @discovery = discovery @principal_sources = principal_sources @submitted = Array(submitted).map(&:to_s) @record = record end |
Instance Method Details
#call ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/karst/access/population_approval.rb', line 26 def call selected = selected_candidates return rejected("Select at least one current candidate population.") if @submitted.empty? return rejected("A submitted population is no longer available for this principal source.") unless selected entries = @record.entries + selected.map do |candidate| PopulationApprovals::Entry.new(model_name: candidate.model_name, method_name: candidate.method_name.to_s) end record = PopulationApprovals.replace(entries) Result.new(record: record, error: record.error) end |