Sha256: 7b25426e4d91a11d6a7b8bd66e84341d378c380fb687200903de955e77b93f58

Contents?: true

Size: 487 Bytes

Versions: 5

Compression:

Stored size: 487 Bytes

Contents

module FileContainer
  mattr_reader :types
  
  @@types ||= []

  def self.included(base)
    @@types << base
  
    base.instance_eval do
      include Associations
    end
  end
  
  def self.all
    types.collect do |type|
      type.all
    end.flatten! || []
  end

  module Associations
    def self.included(base)
      base.instance_eval do
        has_many :file_attachments, {
          :as => :attachable,
          :dependent => :destroy
        }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
file_share-0.1.4 app/models/file_container.rb
file_share-0.1.3 app/models/file_container.rb
file_share-0.1.2 app/models/file_container.rb
file_share-0.1.1 app/models/file_container.rb
file_share-0.1.0 app/models/file_container.rb