Class: WizardFieldChoiceSerializer

Inherits:
ApplicationSerializer show all
Defined in:
app/serializers/wizard_field_choice_serializer.rb

Instance Method Summary collapse

Methods inherited from ApplicationSerializer

expire_cache_fragment!, fragment_cache

Methods inherited from ActiveModel::Serializer

#include!

Instance Method Details

#dataObject



47
48
49
50
51
# File 'app/serializers/wizard_field_choice_serializer.rb', line 47

def data
  result = object.data.dup
  result.delete(:id)
  result
end

#descriptionObject



31
32
33
# File 'app/serializers/wizard_field_choice_serializer.rb', line 31

def description
  I18n.t("#{i18nkey}.description", default: "")
end

#extra_labelObject



23
24
25
# File 'app/serializers/wizard_field_choice_serializer.rb', line 23

def extra_label
  object.extra_label
end

#i18nkeyObject



10
11
12
13
14
# File 'app/serializers/wizard_field_choice_serializer.rb', line 10

def i18nkey
  field = object.field
  step = field.step
  "wizard.step.#{step.id}.fields.#{field.id}.choices.#{id}"
end

#iconObject



39
40
41
# File 'app/serializers/wizard_field_choice_serializer.rb', line 39

def icon
  object.icon
end

#idObject



6
7
8
# File 'app/serializers/wizard_field_choice_serializer.rb', line 6

def id
  object.id
end

#include_data?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'app/serializers/wizard_field_choice_serializer.rb', line 53

def include_data?
  object.data.present?
end

#include_description?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'app/serializers/wizard_field_choice_serializer.rb', line 35

def include_description?
  description.present?
end

#include_extra_label?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/serializers/wizard_field_choice_serializer.rb', line 27

def include_extra_label?
  object.extra_label.present?
end

#include_icon?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'app/serializers/wizard_field_choice_serializer.rb', line 43

def include_icon?
  object.icon.present?
end

#labelObject



16
17
18
19
20
21
# File 'app/serializers/wizard_field_choice_serializer.rb', line 16

def label
  return object.label if object.label.present?

  # Try getting one from a translation
  I18n.t("#{i18nkey}.label", default: id)
end