Sha256: 199cdf36a12d7f58c02530062e2afd00c162e7c96d67e3ff7fcf5fb45ca40efe

Contents?: true

Size: 375 Bytes

Versions: 8

Compression:

Stored size: 375 Bytes

Contents

module Redde::Photoable
  extend ActiveSupport::Concern

  included do
    belongs_to :imageable, polymorphic: true
    default_scope { order(:position) }
    before_save :set_token, unless: :persisted_link?
  end

  def set_token
    token = SecureRandom.uuid unless token.present?
  end

  def persisted_link?
    imageable_type.present? && imageable_id.present?
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
redde-0.1.18 lib/redde/concerns/photoable.rb
redde-0.1.17 lib/redde/concerns/photoable.rb
redde-0.1.16 lib/redde/concerns/photoable.rb
redde-0.1.15 lib/redde/concerns/photoable.rb
redde-0.1.14 lib/redde/concerns/photoable.rb
redde-0.1.13 lib/redde/concerns/photoable.rb
redde-0.1.12 lib/redde/concerns/photoable.rb
redde-0.1.11 lib/redde/concerns/photoable.rb