<commit_before>require 'cancan'

module AttrAbility
  module Controller
    class ControllerResource < CanCan::ControllerResource
      def resource_base
        super.as(current_ability)
      end

      def load_resource_instance
        super.as(current_ability)
      end
    end
  end
end<commit_msg>When cancan is building new resource assign defaults first then params<commit_after>require 'cancan'

module AttrAbility
  module Controller
    class ControllerResource < CanCan::ControllerResource
      def load_resource_instance
        super.as(current_ability)
      end

      protected

      def build_resource
        resource = resource_base.new.as(current_ability)
        resource.send("#{parent_name}=", parent_resource) if @options[:singleton] && parent_resource
        initial_attributes.each do |attr_name, value|
          resource.send("#{attr_name}=", value)
        end
        resource.attributes = @params[name] if @params[name].present?
        resource
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.06930693069306931, 'fraction_numerical': 0.0, 'mean_word_length': 3.0766129032258065, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3012331', 'n_tokens_mistral': 273, 'n_tokens_neox': 271, 'n_words': 68}