Module: Groovestack::Auth::AuthorizedFieldsForSerialization

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/groovestack/auth/authorized_fields_for_serialization.rb

Instance Method Summary collapse

Instance Method Details

#authorized_fields_for_serialization(user) ⇒ Object

required for memoization during graphql serialization



9
10
11
12
13
14
15
16
17
18
# File 'app/models/concerns/groovestack/auth/authorized_fields_for_serialization.rb', line 9

def authorized_fields_for_serialization(user)
  @authorized_fields_for_serialization ||= begin
    Pundit.policy!(user, self).permitted_attributes_for_show
  rescue StandardError => e
    # NOTE: this is a fallback for when Pundit is not available
    ::Groovestack::Base.notify_error(e)

    []
  end
end