Skip to content

Commit 2ae00f7

Browse files
authored
Merge pull request #764 from cerebris/doc_pr751
Doc pr751
2 parents e0120b8 + 2a43caf commit 2ae00f7

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,14 @@ JSONAPI.configure do |config|
19281928
# Controls the serialization of resource linkage for non compound documents
19291929
# NOTE: always_include_to_many_linkage_data is not currently implemented
19301930
config.always_include_to_one_linkage_data = false
1931+
1932+
# Allows transactions for creating and updating records
1933+
# Set this to false if your backend does not support transactions (e.g. Mongodb)
1934+
self.allow_transactions = true
1935+
1936+
# Formatter Caching
1937+
# Set to false to disable caching of string operations on keys and links.
1938+
self.cache_formatters = true
19311939
end
19321940
```
19331941

lib/jsonapi/configuration.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Configuration
2121
:top_level_meta_record_count_key,
2222
:top_level_meta_include_page_count,
2323
:top_level_meta_page_count_key,
24+
:allow_transactions,
2425
:exception_class_whitelist,
2526
:always_include_to_one_linkage_data,
2627
:always_include_to_many_linkage_data,
@@ -80,6 +81,10 @@ def initialize
8081
# for a Resource.
8182
self.default_processor_klass = JSONAPI::Processor
8283

84+
# Allows transactions for creating and updating records
85+
# Set this to false if your backend does not support transactions (e.g. Mongodb)
86+
self.allow_transactions = true
87+
8388
# Formatter Caching
8489
# Set to false to disable caching of string operations on keys and links.
8590
self.cache_formatters = true
@@ -172,6 +177,8 @@ def default_processor_klass=(default_processor_klass)
172177

173178
attr_writer :top_level_meta_page_count_key
174179

180+
attr_writer :allow_transactions
181+
175182
attr_writer :exception_class_whitelist
176183

177184
attr_writer :always_include_to_one_linkage_data

lib/jsonapi/operation_dispatcher.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ def process(operations)
1616
# Use transactions if more than one operation and if one of the operations can be transactional
1717
# Even if transactional transactions won't be used unless the derived OperationsProcessor supports them.
1818
transactional = false
19+
1920
operations.each do |operation|
2021
transactional |= operation.transactional?
21-
end
22+
end if JSONAPI.configuration.allow_transactions
2223

2324
transaction(transactional) do
2425
# Links and meta data global to the set of operations

0 commit comments

Comments
 (0)