Module: Transloadit::Rails::ParamsDecoder

Extended by:
ActiveSupport::Concern
Defined in:
lib/transloadit/rails/params_decoder.rb

Instance Method Summary collapse

Instance Method Details

#decode_transloadit_jsonObject



14
15
16
# File 'lib/transloadit/rails/params_decoder.rb', line 14

def decode_transloadit_json
  params[:transloadit] = transloadit_params
end

#transloadit?Boolean

Returns true if the current request has transloadit data.

Returns:

  • (Boolean)


19
20
21
# File 'lib/transloadit/rails/params_decoder.rb', line 19

def transloadit?
  params[:transloadit].present?
end

#transloadit_paramsObject

Returns the decoded transloadit parameters, or nil if the current request does not contain them.



24
25
26
27
28
29
30
31
# File 'lib/transloadit/rails/params_decoder.rb', line 24

def transloadit_params
  return unless transloadit?

  # wrap transloadit params in a HashWithIndifferentAccess
  ActiveSupport::HashWithIndifferentAccess.new(
    ActiveSupport::JSON.decode params[:transloadit]
  )
end