Class: AccountSerializer

Inherits:
AbstractSerializer show all
Defined in:
app/serializers/account_serializer.rb

Class Method Summary collapse

Methods inherited from AbstractSerializer

opts, serialize

Class Method Details

.active(account) ⇒ Object



13
14
15
# File 'app/serializers/account_serializer.rb', line 13

def active()
  { active: .active }
end

.available_attributesObject



3
4
5
6
7
8
9
10
11
# File 'app/serializers/account_serializer.rb', line 3

def available_attributes
  i[
    active
    created_at
    id
    type_index
    props
  ]
end

.created_at(account) ⇒ Object



17
18
19
# File 'app/serializers/account_serializer.rb', line 17

def created_at()
  { created_at: .created_at }
end

.id(account) ⇒ Object



21
22
23
# File 'app/serializers/account_serializer.rb', line 21

def id()
  { id: .id }
end

.props(account) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/serializers/account_serializer.rb', line 29

def props()
  props = case .type_id
            when ::Dicts::AccountType::MANAGER_GUEST.id
              mg = .manager_guest
              {
                  radius: mg.radius.to_i
              }
            else
              {}
          end
  { props: props }
end

.type_index(account) ⇒ Object



25
26
27
# File 'app/serializers/account_serializer.rb', line 25

def type_index()
  { type_index: ::Dicts::AccountType.find(.type_id).index }
end