Class: Ckeditor::AssetResponse
- Inherits:
-
Object
- Object
- Ckeditor::AssetResponse
- Defined in:
- lib/ckeditor/asset_response.rb
Instance Attribute Summary collapse
-
#asset ⇒ Object
readonly
Returns the value of attribute asset.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #ckeditor? ⇒ Boolean
- #current_mode ⇒ Object
- #errors ⇒ Object
- #file ⇒ Object
-
#initialize(asset, request) ⇒ AssetResponse
constructor
A new instance of AssetResponse.
- #json? ⇒ Boolean
- #success(relative_url_root = nil) ⇒ Object
Constructor Details
#initialize(asset, request) ⇒ AssetResponse
Returns a new instance of AssetResponse.
5 6 7 8 9 10 11 |
# File 'lib/ckeditor/asset_response.rb', line 5 def initialize(asset, request) @asset = asset @request = request @params = request.params @asset.data = Ckeditor::Http.normalize_param(file, @request) end |
Instance Attribute Details
#asset ⇒ Object (readonly)
Returns the value of attribute asset.
3 4 5 |
# File 'lib/ckeditor/asset_response.rb', line 3 def asset @asset end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/ckeditor/asset_response.rb', line 3 def params @params end |
Instance Method Details
#ckeditor? ⇒ Boolean
17 18 19 |
# File 'lib/ckeditor/asset_response.rb', line 17 def ckeditor? !params[:CKEditor].blank? end |
#current_mode ⇒ Object
25 26 27 |
# File 'lib/ckeditor/asset_response.rb', line 25 def current_mode @current_mode ||= extract_mode end |
#errors ⇒ Object
33 34 35 |
# File 'lib/ckeditor/asset_response.rb', line 33 def errors send("errors_#{current_mode}") end |
#file ⇒ Object
21 22 23 |
# File 'lib/ckeditor/asset_response.rb', line 21 def file !(ckeditor? || json?) ? params[:qqfile] : params[:upload] end |
#json? ⇒ Boolean
13 14 15 |
# File 'lib/ckeditor/asset_response.rb', line 13 def json? params[:responseType] == 'json' end |
#success(relative_url_root = nil) ⇒ Object
29 30 31 |
# File 'lib/ckeditor/asset_response.rb', line 29 def success(relative_url_root = nil) send("success_#{current_mode}", relative_url_root) end |