diff --git a/lib/active_interaction/extras/filter_alias.rb b/lib/active_interaction/extras/filter_alias.rb index ca35238..2c0f75c 100644 --- a/lib/active_interaction/extras/filter_alias.rb +++ b/lib/active_interaction/extras/filter_alias.rb @@ -1,16 +1,42 @@ # frozen_string_literal: true # Add :as option, which is a read alias to filter -# hash :params, as: :account_attributes +# hash :account, as: :account_attributes # module ActiveInteraction::Extras::FilterAlias extend ActiveSupport::Concern + # concern :InputsExtension do + # def normalize(inputs) + # @base.class.filters.each do |name, filter| + # alias_name = filter.options[:as] + # + # if alias_name.nil? + # next + # + # elsif inputs.key?(alias_name.to_sym) + # inputs[name.to_sym] = inputs[alias_name.to_sym] + # + # elsif inputs.key?(alias_name.to_s) + # inputs[name.to_s] = inputs[alias_name.to_s] + # end + # end + # + # super + # end + # end + # + # included do + # ActiveInteraction::Inputs.prepend InputsExtension + # end + class_methods do def initialize_filter(filter) super.tap do if filter.options[:as] - alias_method filter.options[:as], filter.name + name = filter.options[:as] + alias_method name, filter.name + # alias_method "#{name}=", "#{filter.name}=" end end end