Class: Ckeditor::AssetResponse

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::JavaScriptHelper, ActionView::Helpers::TagHelper
Defined in:
lib/ckeditor/asset_response.rb

Constant Summary collapse

FUNCTION =
'window.parent.CKEDITOR.tools.callFunction'
JSON_TYPE =
'json'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(asset, request) ⇒ AssetResponse

Returns a new instance of AssetResponse.



16
17
18
19
20
# File 'lib/ckeditor/asset_response.rb', line 16

def initialize(asset, request)
  @asset = asset
  @request = request
  @params = request.params
end

Instance Attribute Details

#assetObject (readonly)

Returns the value of attribute asset.



14
15
16
# File 'lib/ckeditor/asset_response.rb', line 14

def asset
  @asset
end

#paramsObject (readonly)

Returns the value of attribute params.



14
15
16
# File 'lib/ckeditor/asset_response.rb', line 14

def params
  @params
end

#requestObject (readonly)

Returns the value of attribute request.



14
15
16
# File 'lib/ckeditor/asset_response.rb', line 14

def request
  @request
end

Instance Method Details

#ckeditor?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/ckeditor/asset_response.rb', line 30

def ckeditor?
  !params[:CKEditor].blank?
end

#current_modeObject



38
39
40
# File 'lib/ckeditor/asset_response.rb', line 38

def current_mode
  @current_mode ||= extract_mode
end

#dataObject



22
23
24
# File 'lib/ckeditor/asset_response.rb', line 22

def data
  @data ||= read_data
end

#errorsObject



46
47
48
# File 'lib/ckeditor/asset_response.rb', line 46

def errors
  send("errors_#{current_mode}")
end

#fileObject



34
35
36
# File 'lib/ckeditor/asset_response.rb', line 34

def file
  !(ckeditor? || json?) ? params[:qqfile] : params[:upload]
end

#json?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/ckeditor/asset_response.rb', line 26

def json?
  params[:responseType] == JSON_TYPE
end

#success(relative_url_root = nil) ⇒ Object



42
43
44
# File 'lib/ckeditor/asset_response.rb', line 42

def success(relative_url_root = nil)
  send("success_#{current_mode}", relative_url_root)
end