README.md in materialist-3.7.0 vs README.md in materialist-3.8.0
- old
+ new
@@ -153,12 +153,12 @@
sidekiq_options queue: :orderweb_service, retry: false
persist_to :zone
- source_key :source_id do |url|
- /(\d+)\/?$/.match(url)[1]
+ source_key :source_id do |url, response|
+ /(\d+)\/?$/.match(url)[1] # or response.dig(:some_attr)
end
capture :id, as: :orderweb_id
capture :code
capture :name
@@ -187,13 +187,13 @@
#### `persist_to <model_name>`
describes the name of the active record model to be used.
If missing, materialist skips materialising the resource itself, but will continue
with any other functionality -- such as `materialize_link`.
-#### `source_key <column> <url_parser_block> (default: url)`
+#### `source_key <column> <parser_block> (default: url, resource response body[create, update action only])`
describes the column used to persist the unique identifier parsed from the url_parser_block.
By default the column used is `:source_url` and the original `url` is used as the identifier.
-Passing an optional block allows you to extract an identifier from the URL.
+Passing an optional block allows you to extract an identifier from the URL and captured attributes.
#### `capture <key>, as: <column> (default: key)`
describes mapping a resource key to a database column.
You can optionally provide a block for parsing the value: