Sha256: 7d2358c60b2a488fe44d0712995ffd85abe10a4afe4eb74464b2f73c2dbf4f06

Contents?: true

Size: 796 Bytes

Versions: 42

Compression:

Stored size: 796 Bytes

Contents

module ActiveGraph::Shared
  module PermittedAttributes
    extend ActiveSupport::Concern
    include ActiveModel::ForbiddenAttributesProtection

    def process_attributes(attributes)
      attributes = sanitize_input_parameters(attributes)
      super(attributes)
    end

    def attributes=(attributes)
      attributes = sanitize_input_parameters(attributes)
      super(attributes)
    end

    protected

    # Check if an argument is a string or an ActionController::Parameters
    def hash_or_parameter?(args)
      args.is_a?(Hash) || args.respond_to?(:to_unsafe_h)
    end

    def sanitize_input_parameters(attributes)
      attributes = sanitize_for_mass_assignment(attributes)
      attributes.respond_to?(:symbolize_keys) ? attributes.symbolize_keys : attributes
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
activegraph-10.0.0.pre.beta.2 lib/active_graph/shared/permitted_attributes.rb
activegraph-10.0.0.pre.beta.1 lib/active_graph/shared/permitted_attributes.rb