Module: Materialist::Materializer::Internals::DSL
- Defined in:
- lib/materialist/materializer/internals/dsl.rb
Instance Method Summary collapse
- #after_destroy(*method_array) ⇒ Object
- #after_upsert(*method_array) ⇒ Object
- #before_destroy(*method_array) ⇒ Object
- #before_upsert(*method_array) ⇒ Object
-
#before_upsert_with_payload(*method_array) ⇒ Object
This method is meant to be used for cases when the application needs to have access to the ‘payload` that is returned on the HTTP call.
- #capture(key, as: key, &value_parser_block) ⇒ Object
- #capture_link_href(key, as:, &url_parser_block) ⇒ Object
- #link(key, enable_caching: false) ⇒ Object
- #materialize_link(key, topic: key) ⇒ Object
- #persist_to(klass) ⇒ Object
- #sidekiq_options(options) ⇒ Object
- #source_key(key, &source_key_parser) ⇒ Object
Instance Method Details
#after_destroy(*method_array) ⇒ Object
63 64 65 |
# File 'lib/materialist/materializer/internals/dsl.rb', line 63 def after_destroy(*method_array) [:after_destroy] = method_array end |
#after_upsert(*method_array) ⇒ Object
59 60 61 |
# File 'lib/materialist/materializer/internals/dsl.rb', line 59 def after_upsert(*method_array) [:after_upsert] = method_array end |
#before_destroy(*method_array) ⇒ Object
67 68 69 |
# File 'lib/materialist/materializer/internals/dsl.rb', line 67 def before_destroy(*method_array) [:before_destroy] = method_array end |
#before_upsert(*method_array) ⇒ Object
55 56 57 |
# File 'lib/materialist/materializer/internals/dsl.rb', line 55 def before_upsert(*method_array) [:before_upsert] = method_array end |
#before_upsert_with_payload(*method_array) ⇒ Object
This method is meant to be used for cases when the application needs to have access to the ‘payload` that is returned on the HTTP call. Such an example would be if the application logic requires all relationships to be present before the `resource` is saved in the database. Introduced in github.com/deliveroo/materialist/pull/47
51 52 53 |
# File 'lib/materialist/materializer/internals/dsl.rb', line 51 def before_upsert_with_payload(*method_array) [:before_upsert_with_payload] = method_array end |
#capture(key, as: key, &value_parser_block) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/materialist/materializer/internals/dsl.rb', line 9 def capture(key, as: key, &value_parser_block) __materialist_dsl_mapping_stack.last << FieldMapping.new( key: key, as: as, value_parser: value_parser_block ) end |
#capture_link_href(key, as:, &url_parser_block) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/materialist/materializer/internals/dsl.rb', line 17 def capture_link_href(key, as:, &url_parser_block) __materialist_dsl_mapping_stack.last << LinkHrefMapping.new( key: key, as: as, url_parser: url_parser_block ) end |
#link(key, enable_caching: false) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/materialist/materializer/internals/dsl.rb', line 25 def link(key, enable_caching: false) link_mapping = LinkMapping.new(key: key, enable_caching: enable_caching) __materialist_dsl_mapping_stack.last << link_mapping __materialist_dsl_mapping_stack << link_mapping.mapping yield __materialist_dsl_mapping_stack.pop end |
#materialize_link(key, topic: key) ⇒ Object
5 6 7 |
# File 'lib/materialist/materializer/internals/dsl.rb', line 5 def materialize_link(key, topic: key) [:links_to_materialize][key] = { topic: topic } end |
#persist_to(klass) ⇒ Object
33 34 35 |
# File 'lib/materialist/materializer/internals/dsl.rb', line 33 def persist_to(klass) [:model_class] = klass end |
#sidekiq_options(options) ⇒ Object
37 38 39 |
# File 'lib/materialist/materializer/internals/dsl.rb', line 37 def () [:sidekiq_options] = end |
#source_key(key, &source_key_parser) ⇒ Object
41 42 43 44 |
# File 'lib/materialist/materializer/internals/dsl.rb', line 41 def source_key(key, &source_key_parser) [:source_key] = key [:source_key_parser] = source_key_parser end |