Class: InstantRecord::MutationsController

Inherits:
ActionController::API
  • Object
show all
Defined in:
app/controllers/instant_record/mutations_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

Accepts a batch of client mutations; MutationApplier owns the sync semantics (idempotency, LWW, versioning, change logging).



11
12
13
14
15
16
17
18
19
# File 'app/controllers/instant_record/mutations_controller.rb', line 11

def create
  results = Array(params.require(:mutations)).map do |raw|
    MutationApplier.apply(
      raw.permit(:id, :record_type, :record_id, :operation, :base_version, changes: {})
    )
  end

  render json: { results: results }
end

#preflightObject



5
6
7
# File 'app/controllers/instant_record/mutations_controller.rb', line 5

def preflight
  head :no_content
end