metamaps--metamaps/app/serializers/api/v2/user_serializer.rb

27 lines
644 B
Ruby
Raw Permalink Normal View History

2016-09-24 03:00:46 +00:00
# frozen_string_literal: true
module Api
module V2
class UserSerializer < ApplicationSerializer
attributes :id,
2016-09-24 03:00:46 +00:00
:name,
:avatar,
:generation
2016-10-04 14:24:47 +00:00
attribute :is_admin,
if: -> { scope[:show_full_user] && scope[:current_user] == object }
attribute :email,
if: -> { scope[:show_full_user] && scope[:current_user] == object }
2016-10-04 14:24:47 +00:00
def avatar
object.image.url(:sixtyfour)
end
2016-09-24 04:27:34 +00:00
# rubocop:disable Style/PredicateName
def is_admin
object.admin
end
2016-09-24 04:27:34 +00:00
# rubocop:enable Style/PredicateName
end
end
end