Sha256: 4f15aece490154523b8dde880e0c9541b67e9c96b15464e130a551a5627aa00f

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

module BulletTrain
  module Api
    class StrongParametersReporter
      def initialize(model, strong_params_module)
        @model = model
        @module = strong_params_module
        @filters = []
        extend @module
      end

      def require(namespace)
        @namespace = namespace
        self
      end

      def permit(*filters)
        @filters = filters
      end

      def params
        self
      end

      def permitted_fields
        defined?(super) ? super : []
      end

      def permitted_arrays
        defined?(super) ? super : {}
      end

      def process_params(params)
      end

      # def method_missing(method_name, *args)
      #   if method_name.match?(/^assign_/)
      #     # It's typically the second argument that represents the parameter that would be set.
      #     @filters << args[1]
      #   else
      #     raise NoMethodError, message
      #   end
      # end

      def report
        @filters = send(:"#{@model.name.split("::").last.underscore}_params")

        # There's a reason I'm doing it this way.
        @filters
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bullet_train-api-1.7.10 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.7.9 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.7.3 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.7.2 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.7.1 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.7.0 lib/bullet_train/api/strong_parameters_reporter.rb