diff --git a/CHANGES.md b/CHANGES.md index 37e0f72..24591c2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +# 2.1.16 + +* Fix a bug in `patch` where `Subprocess()` was missing in `Macro::Strategy`. +* Introduce `Model::Build` and `Model::Find` macros, which are a replacement for the less + customizable `Model()`. See https://trailblazer.to/2.1/docs/macro/#macro-model-model-find + # 2.1.15 * Use `Macro.id_for` for `Rescue`, meaning IDs will now be consistent à la `Rescue/1` instead of `Rescue(1)`. diff --git a/lib/trailblazer/macro/model/find.rb b/lib/trailblazer/macro/model/find.rb index 246c595..8f48d54 100644 --- a/lib/trailblazer/macro/model/find.rb +++ b/lib/trailblazer/macro/model/find.rb @@ -16,17 +16,17 @@ def self.Find(model_class, positional_method = nil, find_method: nil, id: "model params_key, block, finder_step_options = if positional_method - bla_explicit_positional(model_class, positional_method, **keyword_options, &block) + for_explicit_positional(model_class, positional_method, **keyword_options, &block) elsif find_method.nil? && query.nil? # translate_from_shorthand - bla_shorthand(model_class, **keyword_options, &block) + for_shorthand(model_class, **keyword_options, &block) else # options passed explicitly, kws. this still means we need to translate find_method to query, or use user's query. # TODO: sort out query: default it or take user's if query.nil? - blubb_bla_keywords(model_class, find_method: find_method, **keyword_options, &block) + for_keywords(model_class, find_method: find_method, **keyword_options, &block) else # raise "IMPLEMENT ME" - blubb_bla_query(model_class, query, **keyword_options, &block) + for_query(model_class, query, **keyword_options, &block) end end @@ -48,7 +48,7 @@ def self.normalize_keys(column_key: :id, params_key: column_key, **) return params_key, column_key end - def self.bla_shorthand(model_class, **options, &block) + def self.for_shorthand(model_class, **options, &block) # translate shorthand form. find_method_name, column_key = options.to_a[0] @@ -61,7 +61,7 @@ def self.bla_shorthand(model_class, **options, &block) ] end - def self.bla_explicit_positional(model_class, positional_method, **options, &block) + def self.for_explicit_positional(model_class, positional_method, **options, &block) params_key, _ = normalize_keys(**options) [ @@ -71,7 +71,7 @@ def self.bla_explicit_positional(model_class, positional_method, **options, &blo ] end - def self.blubb_bla_keywords(model_class, find_method:, **options, &block) # FIXME: defaulting is redundant with bla_explicit_positional. + def self.for_keywords(model_class, find_method:, **options, &block) # FIXME: defaulting is redundant with bla_explicit_positional. params_key, column_key = normalize_keys(**options) finder = Find::KeywordArguments.new(model_class: model_class, find_method: find_method, column_key: column_key) @@ -79,7 +79,7 @@ def self.blubb_bla_keywords(model_class, find_method:, **options, &block) # FIXM [params_key, block, finder] end - def self.blubb_bla_query(model_class, query, column_key: :id, params_key: column_key, **, &block) # FIXME: defaulting is redundant with bla_explicit_positional. + def self.for_query(model_class, query, column_key: :id, params_key: column_key, **, &block) # FIXME: defaulting is redundant with bla_explicit_positional. query_on_model_class = ->(ctx, **kws) { model_class.instance_exec(ctx, **kws, &query) } # FIXME: we can only use procs here. what about methods, classes etc? finder = Macro.task_adapter_for_decider(query_on_model_class, variable_name: :model) # FIXME: {:model} is hard-coded.