Class: Alchemy::Custom::Model::ElFinder::Paths::ActiveRecordReference

Inherits:
Base
  • Object
show all
Defined in:
lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb

Direct Known Subclasses

ComponentFile, File

Constant Summary collapse

URI_SPACER =
'___'

Instance Attribute Summary

Attributes inherited from Base

#path, #root, #volume

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#absolute?, #basename, #basename_sans_extension, #child_directories, #children, #cleanpath, #dirname, #duplicate, #extname, #full_fill_paylod, #fullpath, #global_id, #initialize, #is_image?, #is_root?, #mime_type, #name, #outside_of_root?, #realpath, #relative?, #relative_to, #rename, #tmb, #to_s, #unique, #with_sub_dirs?

Constructor Details

This class inherits a constructor from Alchemy::Custom::Model::ElFinder::Paths::Base

Class Method Details

.file_to_uri(p) ⇒ Object



33
34
35
36
# File 'lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb', line 33

def self.file_to_uri(p)
  #p.to_global_id.uri.to_s.gsub(/^gid\:\/\//,'')
  "#{p.id}#{URI_SPACER}"
end

Instance Method Details

#active_record_classObject



16
17
18
# File 'lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb', line 16

def active_record_class
  raise "ToOverride"
end

#active_record_instanceObject



24
25
26
27
28
29
30
31
# File 'lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb', line 24

def active_record_instance
  return @_active_record_instance if @_active_record_instance
  id = self.path.basename.to_s.split(URI_SPACER).first
  @_active_record_instance = self.active_record_class.find(id)

  # gid = "gid://#{self.path.basename.to_s}"#.split(URI_SPACER)
  # @_active_record_instance = GlobalID::Locator.locate gid# self.active_record_class.find(id)
end

#active_record_instance=(v) ⇒ Object



20
21
22
# File 'lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb', line 20

def active_record_instance=(v)
  @_active_record_instance = v
end

#directory?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb', line 12

def directory?
  false
end

#fileObject



47
48
49
# File 'lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb', line 47

def file
  active_record_instance.file
end

#file?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb', line 8

def file?
  true
end

#fisical_pathObject



51
52
53
# File 'lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb', line 51

def fisical_path
  file.path
end

#mtimeObject

Identifichiamo la data di modifica del file con la data di modifica del record, in questo modo la cache che viene generata attraverso l'inserimento di un parametro nella query con il valore t=orario non andrĂ  ad essere aggiornato ad ogni refresh, anche solo a livello di browser nel caso abbiamo problemi usiamo lo standard



43
44
45
# File 'lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb', line 43

def mtime
  active_record_instance.updated_at rescue super
end