Class: Synchronisable::Input::Parser Private
- Defined in:
- lib/synchronisable/input/parser.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Responsible for guessing the user input format.
Instance Method Summary collapse
-
#initialize(model, synchronizer) ⇒ Parser
constructor
private
A new instance of Parser.
-
#parse(data) ⇒ Array<Hash>
private
Parses the user input.
Constructor Details
#initialize(model, synchronizer) ⇒ Parser
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Parser.
11 12 13 14 |
# File 'lib/synchronisable/input/parser.rb', line 11 def initialize(model, synchronizer) @model = model @synchronizer = synchronizer end |
Instance Method Details
#parse(data) ⇒ Array<Hash>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Parses the user input.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/synchronisable/input/parser.rb', line 22 def parse(data) input = Descriptor.new(data) result = case when input.empty? @synchronizer.fetch when input.params? find_or_fetch_by_params(input.data) when input.remote_id? @synchronizer.find(data) when input.local_id? find_by_local_id(data) when input.array_of_ids? find_by_array_of_ids(input) else result = data.dup end [result].flatten.compact end |