Sha256: 65d17e9d9d653131a8ccbdfd4480bff532258bdd3eb64461eda2a582084712d0

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

require 'active_support'

# Core
require 'asset_cloud/asset'
require 'asset_cloud/metadata'
require 'asset_cloud/bucket'
require 'asset_cloud/buckets/active_record_bucket'
require 'asset_cloud/buckets/blackhole_bucket'
require 'asset_cloud/buckets/bucket_chain'
require 'asset_cloud/buckets/file_system_bucket'
require 'asset_cloud/buckets/invalid_bucket'
require 'asset_cloud/buckets/memory_bucket'
require 'asset_cloud/buckets/versioned_memory_bucket'
require 'asset_cloud/base'


# Extensions
require 'asset_cloud/free_key_locator'
require 'asset_cloud/callbacks'
require 'asset_cloud/validations'

require 'asset_cloud/asset_extension'


AssetCloud::Base.class_eval do
  include AssetCloud::FreeKeyLocator
  include AssetCloud::Callbacks
  callback_methods :write, :delete
end

AssetCloud::Asset.class_eval do
  include AssetCloud::Callbacks
  callback_methods :store, :delete

  include AssetCloud::Validations
  callback_methods :validate
  validate :valid_key

  def execute_callbacks(symbol, args)
    super
    @extensions.each {|ext| ext.execute_callbacks(symbol, args)}
  end

  private

  def valid_key
    if key.blank?
      add_error "key cannot be empty"
    elsif key !~ AssetCloud::Base::VALID_PATHS
      add_error "#{key.inspect} contains illegal characters"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
asset_cloud-2.0.0 lib/asset_cloud.rb
asset_cloud-1.1.1 lib/asset_cloud.rb
asset_cloud-1.1.0 lib/asset_cloud.rb
asset_cloud-1.0.2 lib/asset_cloud.rb