Sha256: a7d52576c9e190d6876a69befea25f8e9cf1a4c2007b950f4164cdcb1e3e64c0

Contents?: true

Size: 798 Bytes

Versions: 4

Compression:

Stored size: 798 Bytes

Contents

module Boxroom
  class PermittedParams < Struct.new(:params, :current_user)
    %w{folder group share_link user user_file}.each do |model_name|
      define_method model_name do
        params.require(model_name.to_sym).permit(*send("#{model_name}_attributes"))
      end
    end

    def folder_attributes
      [:name]
    end

    def group_attributes
      [:name]
    end

    def share_link_attributes
      [:emails, :link_expires_at, :message]
    end

    def user_attributes
      if current_user && current_user.member_of_admins?
        [:name, :email, :password, :password_confirmation, {:group_ids => []}]
      else
        [:name, :email, :password, :password_confirmation]
      end
    end

    def user_file_attributes
      [:attachment, :attachment_file_name]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
boxroom-0.0.4 app/models/boxroom/permitted_params.rb
boxroom-0.0.3 app/models/boxroom/permitted_params.rb
boxroom-0.0.2 app/models/boxroom/permitted_params.rb
boxroom-0.0.1 app/models/boxroom/permitted_params.rb