Class: ViewModel::ActiveRecord::AbstractCollectionUpdate::Parser
- Inherits:
-
Object
- Object
- ViewModel::ActiveRecord::AbstractCollectionUpdate::Parser
- Defined in:
- lib/view_model/active_record/update_data.rb
Direct Known Subclasses
OwnedCollectionUpdate::Parser, ReferencedCollectionUpdate::Parser
Instance Method Summary collapse
-
#initialize(association_data, blame_reference, valid_reference_keys) ⇒ Parser
constructor
A new instance of Parser.
- #parse(value) ⇒ Object
Constructor Details
#initialize(association_data, blame_reference, valid_reference_keys) ⇒ Parser
Returns a new instance of Parser.
111 112 113 114 115 |
# File 'lib/view_model/active_record/update_data.rb', line 111 def initialize(association_data, blame_reference, valid_reference_keys) @association_data = association_data @blame_reference = blame_reference @valid_reference_keys = valid_reference_keys end |
Instance Method Details
#parse(value) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/view_model/active_record/update_data.rb', line 117 def parse(value) case value when Array replace_update_type.new(parse_contents(value)) when Hash ViewModel::Schemas.verify_schema!(functional_update_schema, value) functional_updates = value[ACTIONS_ATTRIBUTE].map { |action| parse_action(action) } functional_update_type.new(functional_updates) else raise ViewModel::DeserializationError::InvalidSyntax.new( "Could not parse non-array value for collection association '#{association_data}'", blame_reference) end end |