Sha256: 719a268fc8a2d37503a2e94c06c530611071750dff103ef4a24c7f851e58991d

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'voom/presenters/dsl/components/mixins/event'
require 'voom/presenters/dsl/components/mixins/tooltips'

module Voom
  module Presenters
    module DSL
      module Components
        class Image < EventBase
          include Mixins::Tooltips

          attr_accessor :image, :height, :width, :position, :selected, :url

          def initialize(**attribs_, &block)
            super(type: :image,
                  **attribs_, &block)
            @image = attribs.delete(:image)
            @height = attribs.delete(:height)
            @width = attribs.delete(:width)
            @position = Array(attribs.delete(:position)).compact
            @selected = attribs.delete(:selected)
            @url = build_url
            expand!
          end
          
          private
          def build_url
            return nil unless image
            return image if image.start_with?('/') || @image.start_with?('http')
            @parent.router.url(render: image, context: {})
          end

        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
voom-presenters-0.2.0 lib/voom/presenters/dsl/components/image.rb