Class: ViewModel::ActiveRecord::ReferencedCollectionUpdate::Parser
Instance Method Summary
collapse
#initialize, #parse
Instance Method Details
#append_action_schema ⇒ Object
347
348
349
|
# File 'lib/view_model/active_record/update_data.rb', line 347
def append_action_schema
UpdateData::Schemas::REFERENCED_APPEND_ACTION
end
|
#functional_update_schema ⇒ Object
343
344
345
|
# File 'lib/view_model/active_record/update_data.rb', line 343
def functional_update_schema
UpdateData::Schemas::REFERENCED_COLLECTION_UPDATE
end
|
#parse_contents(values) ⇒ Object
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
|
# File 'lib/view_model/active_record/update_data.rb', line 359
def parse_contents(values)
invalid_entries = values.reject { |h| ref_hash?(h) }
if invalid_entries.present?
raise ViewModel::DeserializationError::InvalidSyntax.new(
"Appended/Updated entities must be specified as '#{ViewModel::REFERENCE_ATTRIBUTE}' style hashes." \
"Invalid entries: #{invalid_entries}",
blame_reference)
end
values.map do |x|
ref = ViewModel.(x)
unless valid_reference_keys.include?(ref)
raise ViewModel::DeserializationError::InvalidSharedReference.new(ref, blame_reference)
end
ref
end
end
|
#remove_action_schema ⇒ Object
351
352
353
|
# File 'lib/view_model/active_record/update_data.rb', line 351
def remove_action_schema
UpdateData::Schemas::REFERENCED_REMOVE_ACTION
end
|
#update_action_schema ⇒ Object
355
356
357
|
# File 'lib/view_model/active_record/update_data.rb', line 355
def update_action_schema
UpdateData::Schemas::REFERENCED_UPDATE_ACTION
end
|