return artifact enum values as integers
This commit is contained in:
parent
0a069c0324
commit
4db5f4224e
2 changed files with 16 additions and 4 deletions
|
|
@ -10,7 +10,12 @@ module Api
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
fields :granblue_id, :proficiency, :rarity
|
fields :granblue_id, :rarity
|
||||||
|
|
||||||
|
# Return proficiency as integer (nil for quirk artifacts)
|
||||||
|
field :proficiency do |a|
|
||||||
|
a.proficiency_before_type_cast
|
||||||
|
end
|
||||||
|
|
||||||
field :release_date, if: ->(_field, a, _options) { a.release_date.present? }
|
field :release_date, if: ->(_field, a, _options) { a.release_date.present? }
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,17 @@ module Api
|
||||||
class CollectionArtifactBlueprint < ApiBlueprint
|
class CollectionArtifactBlueprint < ApiBlueprint
|
||||||
identifier :id
|
identifier :id
|
||||||
|
|
||||||
fields :element, :level, :nickname, :reroll_slot, :created_at, :updated_at
|
fields :level, :nickname, :reroll_slot, :created_at, :updated_at
|
||||||
|
|
||||||
# Proficiency is only present on quirk artifacts
|
# Return element as integer
|
||||||
field :proficiency, if: ->(_field, obj, _options) { obj.proficiency.present? }
|
field :element do |obj|
|
||||||
|
obj.element_before_type_cast
|
||||||
|
end
|
||||||
|
|
||||||
|
# Proficiency is only present on quirk artifacts, return as integer
|
||||||
|
field :proficiency, if: ->(_field, obj, _options) { obj.proficiency.present? } do |obj|
|
||||||
|
obj.proficiency_before_type_cast
|
||||||
|
end
|
||||||
|
|
||||||
field :skills do |obj|
|
field :skills do |obj|
|
||||||
[obj.skill1, obj.skill2, obj.skill3, obj.skill4].map do |skill|
|
[obj.skill1, obj.skill2, obj.skill3, obj.skill4].map do |skill|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue