Sha256: 98355641728579f5f1b9adb71e9d4afb7fd3f45acf64483af39af207852f6e77

Contents?: true

Size: 572 Bytes

Versions: 1

Compression:

Stored size: 572 Bytes

Contents

module Sprangular
  class ImageSerializer < BaseSerializer
    attributes :id, :position, :attachment_content_type, :attachment_file_name,
               :type, :attachment_updated_at, :attachment_width,
               :attachment_height, :alt, :viewable_type, :viewable_id

    def attributes
      super.tap do |attrs|
        image_styles.each_key do |style|
          attrs["#{style}_url"] = object.attachment.url(style)
        end
      end
    end

    private

    def image_styles
      Spree::Image.attachment_definitions[:attachment][:styles]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sprangular-0.1.0 app/serializers/sprangular/image_serializer.rb