Sha256: 8ed462a764fe470a639399c7f8d08cad4535945affc894d45e572e8f70ca31ac

Contents?: true

Size: 1.09 KB

Versions: 116

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".to_sym)

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

Version data entries

116 entries across 116 versions & 1 rubygems

Version Path
bullet_train-api-1.6.38 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.37 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.36 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.35 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.34 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.33 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.32 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.31 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.30 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.29 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.28 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.27 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.26 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.25 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.24 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.23 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.22 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.21 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.20 lib/bullet_train/api/strong_parameters_reporter.rb
bullet_train-api-1.6.19 lib/bullet_train/api/strong_parameters_reporter.rb