Sha256: d86e450463d7ab6f54bc0ca0ef8bc115f9a24fc9f5a6e277d93890d511f48c5c

Contents?: true

Size: 1.23 KB

Versions: 27

Compression:

Stored size: 1.23 KB

Contents

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

      def active_record_class
        self.volume.attribute_class
      end

      def alchemy_record
        return @_alch_record_cache if @_alch_record_cache
        base = active_record_instance
        self.volume.file_link_ref.split('.').each {|m| base = base.try(m)}
        @_alch_record_cache = base
      end

      def file
        case alchemy_record
        when ::Alchemy::Attachment
          alchemy_record.file
        when ::Alchemy::Picture
          alchemy_record.image_file
        end
      end


      def file=(val)
        case alchemy_record
        when ::Alchemy::Attachment
          alchemy_record.file = val
        when ::Alchemy::Picture
          alchemy_record.image_file = val
        end
      end

      delegate :save, to: :alchemy_record

      def full_fill_paylod(payload)
        payload[:tmb] = self.tmb
        payload
      end


      def tmb
        case alchemy_record
        when ::Alchemy::Attachment
          ''
        when ::Alchemy::Picture
          file.thumb('100x100#').url
        end

      end

      def is_image?
        alchemy_record.is_a? ::Alchemy::Picture
      end

    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
alchemy-custom-model-3.2 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-3.1.5 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-3.1.4 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-3.1.3 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-3.1.2 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-3.1.1 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-3.1.0 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-2.2.2 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-3.0.0 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-2.2.1 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-2.2.0 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-2.1.2 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-2.1.1 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-2.1.0 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-2.0.3 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-2.0.2 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-2.0.1 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-2.0.0 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-0.1.9 lib/alchemy/custom/model/el_finder/paths/component_file.rb
alchemy-custom-model-0.1.7 lib/alchemy/custom/model/el_finder/paths/component_file.rb