Class: Synchronisable::InputParser Private
- Inherits:
-
Object
- Object
- Synchronisable::InputParser
- 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) ⇒ InputParser
constructor
private
A new instance of InputParser.
-
#parse(data) ⇒ Array<Hash>
private
Parses the user input.
Constructor Details
#initialize(model, synchronizer) ⇒ InputParser
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 InputParser.
10 11 12 13 |
# File 'lib/synchronisable/input_parser.rb', line 10 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.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/synchronisable/input_parser.rb', line 21 def parse(data) input = InputDescriptor.new(data) result = case when input.empty? @synchronizer.fetch when input.params? find_or_fetch_by_data(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 |