Module: ElephantInTheRoom::TheOneApiSdk::Pipeline::PipelineModifiers
- Included in:
- ApiPaths::Base, ModifiedSdk, TheOne
- Defined in:
- lib/elephant_in_the_room/the_one_api_sdk/pipeline/pipeline_modifiers.rb
Overview
Common methods to work with pipelines
Instance Method Summary collapse
-
#replace_existing_stage(pipeline, next_stage_key, next_stage_lambda) ⇒ Object
Replace a stage in a pipeline with a modified version with different parameters.
- #with_filters(pipeline, filters) {|replace_existing_stage( pipeline, :filter, ->(next_stage) { ElephantInTheRoom::TheOneApiSdk::Pipeline::Filters.new(next_stage, filters) } )| ... } ⇒ Object
- #with_pagination(pipeline, limit: nil, page: nil, offset: nil) {|replace_existing_stage(pipeline, :paginate, new_paginate_stage)| ... } ⇒ Object
- #with_path(pipeline, path) {|replace_existing_stage( pipeline, :set_path, ->(next_stage) { ElephantInTheRoom::TheOneApiSdk::Pipeline::SetPath.new(next_stage, path) } )| ... } ⇒ Object
Instance Method Details
#replace_existing_stage(pipeline, next_stage_key, next_stage_lambda) ⇒ Object
Replace a stage in a pipeline with a modified version with different parameters
9 10 11 12 13 14 15 |
# File 'lib/elephant_in_the_room/the_one_api_sdk/pipeline/pipeline_modifiers.rb', line 9 def replace_existing_stage(pipeline, next_stage_key, next_stage_lambda) lambda { modified_pipeline = pipeline.call modified_pipeline[next_stage_key] = next_stage_lambda modified_pipeline } end |
#with_filters(pipeline, filters) {|replace_existing_stage( pipeline, :filter, ->(next_stage) { ElephantInTheRoom::TheOneApiSdk::Pipeline::Filters.new(next_stage, filters) } )| ... } ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/elephant_in_the_room/the_one_api_sdk/pipeline/pipeline_modifiers.rb', line 25 def with_filters(pipeline, filters) yield replace_existing_stage( pipeline, :filter, ->(next_stage) { ElephantInTheRoom::TheOneApiSdk::Pipeline::Filters.new(next_stage, filters) } ) end |
#with_pagination(pipeline, limit: nil, page: nil, offset: nil) {|replace_existing_stage(pipeline, :paginate, new_paginate_stage)| ... } ⇒ Object
33 34 35 36 37 38 |
# File 'lib/elephant_in_the_room/the_one_api_sdk/pipeline/pipeline_modifiers.rb', line 33 def with_pagination(pipeline, limit: nil, page: nil, offset: nil) new_paginate_stage = lambda { |next_stage| ElephantInTheRoom::TheOneApiSdk::Pipeline::Paginate.new(next_stage, limit: limit, page: page, offset: offset) } yield replace_existing_stage(pipeline, :paginate, new_paginate_stage) end |
#with_path(pipeline, path) {|replace_existing_stage( pipeline, :set_path, ->(next_stage) { ElephantInTheRoom::TheOneApiSdk::Pipeline::SetPath.new(next_stage, path) } )| ... } ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/elephant_in_the_room/the_one_api_sdk/pipeline/pipeline_modifiers.rb', line 17 def with_path(pipeline, path) yield replace_existing_stage( pipeline, :set_path, ->(next_stage) { ElephantInTheRoom::TheOneApiSdk::Pipeline::SetPath.new(next_stage, path) } ) end |