Sha256: 3f576e87798052eb3ed61df71631d28905525d3b34fb2b2eefc6663d9fa548fe

Contents?: true

Size: 721 Bytes

Versions: 2

Compression:

Stored size: 721 Bytes

Contents

#
#   File Manager Model
#   
#   @author Xiterrex & Jnillo
#   @description This module represent instances between files references in other objects of data models.
#                 For example, a post that used a image in his content.
#
#

class FileManager < ActiveRecord::Base
  
  attr_accessible :entity_id, :entity_type, :file

  # Polimorfic relation between this entity and the entities how used files 
  belongs_to :entity, :polymorphic => true

  
   
  # Used In static method
  #
  # @param [String] file reference
  # @return: [List] List of instances of models entities which use this file (Instances entities list)
  def self.used_in(file)
    FileManager.find_all_by_file(file).map(&:entity)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
file_manager_engine-0.0.2 app/models/file_manager.rb
file_manager_engine-0.0.1 app/models/file_manager.rb