Sha256: 96824f316f2cf119b7bb5e75de71c1c3328dc585da63cce7e96b484db33463f2

Contents?: true

Size: 517 Bytes

Versions: 9

Compression:

Stored size: 517 Bytes

Contents

module Alchemy
  class ContentSerializer < ActiveModel::Serializer
    self.root = false

    attributes :id,
      :name,
      :ingredient,
      :element_id,
      :position,
      :created_at,
      :updated_at

    has_one :essence, polymorphic: true

    def ingredient
      case object.essence_type
      when 'Alchemy::EssencePicture'
        object.essence.picture_url
      when 'Alchemy::EssenceFile'
        object.essence.attachment_url
      else
        object.ingredient
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
alchemy_cms-3.0.4 app/serializers/alchemy/content_serializer.rb
alchemy_cms-3.0.3 app/serializers/alchemy/content_serializer.rb
alchemy_cms-3.0.2 app/serializers/alchemy/content_serializer.rb
alchemy_cms-3.0.1 app/serializers/alchemy/content_serializer.rb
alchemy_cms-3.0.0 app/serializers/alchemy/content_serializer.rb
alchemy_cms-3.0.0.rc8 app/serializers/alchemy/content_serializer.rb
alchemy_cms-3.0.0.rc7 app/serializers/alchemy/content_serializer.rb
alchemy_cms-3.0.0.rc6 app/serializers/alchemy/content_serializer.rb
alchemy_cms-3.0.0.rc5 app/serializers/alchemy/content_serializer.rb