Sha256: 4f36c472a40b2a6b1d18d1140c9bf3b7c89f9c2787dbc8e7b5f6e9ca46758bf4

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

# -*- encoding : utf-8 -*-
class Card; module Set; class Abstract; module Attachment;
# Set: Abstract (Attachment, Local)
#
module Local;
extend Card::Set
def self.source_location; "/Users/ezl5238/dev/decko/gem/mod/carrierwave/set/abstract/attachment/local.rb"; end
event :update_public_link_on_create, :integrate, on: :create, when: :local? do
  update_public_link
end

event :remove_public_link_on_delete, :integrate, on: :delete, when: :local? do
  remove_public_links
end

event :update_public_link, after: :update_read_rule, when: :local? do
  return if content.blank?

  if who_can(:read).include? Card::AnyoneID
    create_public_links
  else
    remove_public_links
  end
end

private

def create_public_links
  path = attachment.public_path
  return if File.exist? path

  FileUtils.mkdir_p File.dirname(path)
  File.symlink attachment.path, path unless File.symlink? path
  create_versions_public_links
end

def create_versions_public_links
  attachment.versions.each_value do |version|
    next if File.symlink? version.public_path

    File.symlink version.path, version.public_path
  end
end

def remove_public_links
  symlink_dir = File.dirname attachment.public_path
  return unless Dir.exist? symlink_dir

  FileUtils.rm_rf symlink_dir
end
end;end;end;end;end;
# ~~ generated from /Users/ezl5238/dev/decko/gem/mod/carrierwave/set/abstract/attachment/local.rb ~~

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
card-1.102.0 tmpsets/set/mod013-carrierwave/abstract/attachment/local.rb