module Materialist::Materializer::Internals::DSL
Public Instance Methods
after_destroy(*method_array)
click to toggle source
# File lib/materialist/materializer/internals/dsl.rb, line 63 def after_destroy(*method_array) __materialist_options[:after_destroy] = method_array end
after_upsert(*method_array)
click to toggle source
# File lib/materialist/materializer/internals/dsl.rb, line 59 def after_upsert(*method_array) __materialist_options[:after_upsert] = method_array end
before_destroy(*method_array)
click to toggle source
# File lib/materialist/materializer/internals/dsl.rb, line 67 def before_destroy(*method_array) __materialist_options[:before_destroy] = method_array end
before_upsert(*method_array)
click to toggle source
# File lib/materialist/materializer/internals/dsl.rb, line 55 def before_upsert(*method_array) __materialist_options[:before_upsert] = method_array end
before_upsert_with_payload(*method_array)
click to toggle source
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
# File lib/materialist/materializer/internals/dsl.rb, line 51 def before_upsert_with_payload(*method_array) __materialist_options[:before_upsert_with_payload] = method_array end
capture(key, as: key, &value_parser_block)
click to toggle source
# 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)
click to toggle source
# 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) { || ... }
click to toggle source
# 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)
click to toggle source
# File lib/materialist/materializer/internals/dsl.rb, line 5 def materialize_link(key, topic: key) __materialist_options[:links_to_materialize][key] = { topic: topic } end
persist_to(klass)
click to toggle source
# File lib/materialist/materializer/internals/dsl.rb, line 33 def persist_to(klass) __materialist_options[:model_class] = klass end
sidekiq_options(options)
click to toggle source
# File lib/materialist/materializer/internals/dsl.rb, line 37 def sidekiq_options(options) __materialist_options[:sidekiq_options] = options end
source_key(key, &source_key_parser)
click to toggle source
# File lib/materialist/materializer/internals/dsl.rb, line 41 def source_key(key, &source_key_parser) __materialist_options[:source_key] = key __materialist_options[:source_key_parser] = source_key_parser end