Class: Eco::API::Session::Batch::Feedback
- Extended by:
- Getters, Identifiers
- Includes:
- Generate, JobDependencies, RequestStat
- Defined in:
- lib/eco/api/session/batch/feedback.rb,
lib/eco/api/session/batch/feedback/getters.rb,
lib/eco/api/session/batch/feedback/generate.rb,
lib/eco/api/session/batch/feedback/identifiers.rb,
lib/eco/api/session/batch/feedback/request_stat.rb,
lib/eco/api/session/batch/feedback/request_stats.rb,
lib/eco/api/session/batch/feedback/job_dependencies.rb
Defined Under Namespace
Modules: Generate, Getters, Identifiers, JobDependencies, RequestStat Classes: RequestStats
Instance Attribute Summary collapse
-
#job ⇒ Eco::API::Session::Batch::Job
readonly
batch jobthe feedback is associated with.
Pure feedback methods collapse
-
#as_update(entry, add_feedback: true) ⇒ Object
Slightly modifies the behaviour of
Ecoportal::API::Common::BaseModel#as_update, so schema details fields show thealt_id.
Instance Method Summary collapse
-
#initialize(job:) ⇒ Feedback
constructor
A new instance of Feedback.
Methods included from Getters
Methods included from Identifiers
Methods included from Generate
Methods included from RequestStat
Methods included from JobDependencies
#job_requests, #name, #options, #sets, #type
Constructor Details
#initialize(job:) ⇒ Feedback
Returns a new instance of Feedback.
22 23 24 25 26 27 |
# File 'lib/eco/api/session/batch/feedback.rb', line 22 def initialize(job:) msg = "A Eco::API::Session::Batch::Job object is required. Given: #{job.class}" raise msg unless job.is_a?(Eco::API::Session::Batch::Job) @job = job end |
Instance Attribute Details
#job ⇒ Eco::API::Session::Batch::Job (readonly)
batch job the feedback is associated with
6 7 8 |
# File 'lib/eco/api/session/batch/feedback.rb', line 6 def job @job end |
Instance Method Details
#as_update(entry, add_feedback: true) ⇒ Object
Note:
for better feedback
Slightly modifies the behaviour of Ecoportal::API::Common::BaseModel#as_update,
so schema details fields show the alt_id.
It also fixes possible patch updates that are incomplete or unnecessary.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/eco/api/session/batch/feedback.rb', line 37 def as_update(entry, add_feedback: true) return entry if entry.is_a?(Hash) # assuming entry.is_a?(Ecoportal::API::V1::Person) if only_ids? # @todo entry.respond_to?(:as_json) hash = entry.as_json.slice('id', 'external_id', 'email') else # @todo entry.respond_to?(:as_update) hash = entry.as_update details = hash['details'] h_fields = details && details['fields'] if add_feedback && h_fields h_fields.each do |fld| fld.merge!('alt_id' => entry.details.get_field(fld['id']).alt_id) end end account = hash['account'] invites = account && account.keys == ['send_invites'] ninvites = invites && !account['send_invites'] if ninvites hash.delete('account') hash.delete('id') if hash.keys == ['id'] end end hash || {} end |