Sha256: 380dec49c0e5cffb177b0818fb0bbb01022b6841cb20410670d4db3ff7e30dab

Contents?: true

Size: 1.35 KB

Versions: 2

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/ethan/dev/decko/gem/card-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/ethan/dev/decko/gem/card-mod-carrierwave/set/abstract/attachment/local.rb ~~

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
card-1.101.7 tmpsets/set/mod013-card-mod-carrierwave/abstract/attachment/local.rb
card-1.101.6 tmpsets/set/mod013-card-mod-carrierwave/abstract/attachment/local.rb