Class: Engine2::DownloadForeignBlobStoreMeta

Inherits:
Meta
  • Object
show all
Includes:
BlobSupportMeta
Defined in:
lib/engine2/meta/infra_meta.rb

Instance Attribute Summary

Attributes inherited from Meta

#action, #assets, #invokable, #static

Instance Method Summary collapse

Methods included from BlobSupportMeta

#serve_blob

Methods inherited from Meta

#action_defined, #check_static_meta, #dynamic?, #freeze_meta, #get, http_method, #http_method, inherited, #initialize, #invoke!, #lookup, #merge, #meta_type, meta_type, #post_process, #post_run, #pre_run, #request, #request_meta_proc_params, #split_keys

Constructor Details

This class inherits a constructor from Engine2::Meta

Instance Method Details

#invoke(handler) ⇒ Object



207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/engine2/meta/infra_meta.rb', line 207

def invoke handler
    model = action.parent.*.model
    inf = model.type_info[action.parent.*.field]
    assoc = model.association_reflections[inf[:assoc_name]]
    blob_model = Object.const_get(assoc[:class_name])
    handler.permit id = handler.params[:id]
    rec = model.naked.select(assoc[:key]).where(model.primary_keys_hash(split_keys(id))).first
    handler.permit rec

    entry = blob_model.naked.select(inf[:bytes_field], inf[:name_field], inf[:mime_field]).where(blob_model.primary_key => rec[assoc[:key]]).first
    serve_blob(handler, entry, inf)
end