lib/json-path/builder.rb in json-path-builder-0.1.0 vs lib/json-path/builder.rb in json-path-builder-0.1.1

- old
+ new

@@ -2,11 +2,11 @@ # rubocop:disable Metrics/ClassLength class Builder attr_reader :path_context_collection, :parent_path_context delegate :source_data, :nested_paths, :data_wrapper_class, :reject_from_paths!, to: :path_context_collection, - allow_nil: true + allow_nil: true def initialize(parent_path_context: nil) @parent_path_context = parent_path_context @path_context_collection = PathContextCollection.new(self) end @@ -34,10 +34,11 @@ fallback_proc: fallback, skip_if_proc: nil) self end + # rubocop:enable Metrics/ParameterLists # rubocop:disable Metrics/ParameterLists def from_each(json_path, to: nil, transform: nil, skip_if: nil, defaults: nil, fallback: nil, transform_with_builder: false) @@ -50,10 +51,11 @@ fallback_proc: fallback, skip_if_proc: skip_if) self end + # rubocop:enable Metrics/ParameterLists def with_source_data(data) path_context_collection.with_source_data(data) @@ -139,11 +141,11 @@ value end def transform_value_with_builder(value, path_context) - builder = PathsBuilder.new(parent_path_context: path_context) + builder = Builder.new(parent_path_context: path_context) pb = call_proc(path_context.transform, builder, path_context) return pb.build_for(value) if pb&.paths? value end @@ -170,10 +172,11 @@ apply_defaults(val, path_context) end Rordash::HashUtil.deep_symbolize_keys(value) end + # rubocop:enable Metrics/PerceivedComplexity,Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity def apply_defaults(data, path_context) return data unless data.is_a?(Hash) && path_context.defaults? @@ -209,10 +212,11 @@ call_proc_with_extra_args(proc, filled_args, filled_extra_args) else filled_args.present? ? proc.call(*filled_args) : proc.call end end + # rubocop:enable Metrics/PerceivedComplexity,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/AbcSize def call_proc_with_extra_args(proc, args, **extra_args) if args.present? args.first.is_a?(Hash) ? proc.call(**args.first) : proc.call @@ -226,7 +230,8 @@ def keys path_context_collection.map(&:to) end end + # rubocop:enable Metrics/ClassLength end