Sha256: 79e0bcb22386c4aca09f80a2f1ee98763c7d1bdbb85264387a21ecfe7289861a

Contents?: true

Size: 1.13 KB

Versions: 18

Compression:

Stored size: 1.13 KB

Contents

module Alchemy::Custom::Model::ElFinder
    module Paths
      class ActiveRecordReference < Base


        URI_SPACER = '___'

        def file?
          true
        end

        def directory?
          false
        end

        def active_record_class
          raise "ToOverride"
        end

        def active_record_instance=(v)
          @_active_record_instance = v
        end

        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

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

        def file
          active_record_instance.file
        end

        def fisical_path
          file.path
        end

        delegate :name, :mime_type, :size, to: :file

      end
    end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
alchemy-custom-model-2.2.1 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb
alchemy-custom-model-2.2.0 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb
alchemy-custom-model-2.1.2 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb
alchemy-custom-model-2.1.1 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb
alchemy-custom-model-2.1.0 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb
alchemy-custom-model-2.0.3 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb
alchemy-custom-model-2.0.2 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb
alchemy-custom-model-2.0.1 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb
alchemy-custom-model-2.0.0 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb
alchemy-custom-model-0.1.9 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb
alchemy-custom-model-0.1.7 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb
alchemy-custom-model-0.1.6 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb
alchemy-custom-model-0.1.5 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb
alchemy-custom-model-0.1.4 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb
alchemy-custom-model-0.1.3 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb
alchemy-custom-model-0.1.2 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb
alchemy-custom-model-0.1.1 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb
alchemy-custom-model-0.1.0 lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb