Class: Cytoplasm::Ajax
- Inherits:
-
AbstractController::Base
- Object
- AbstractController::Base
- Cytoplasm::Ajax
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/cytoplasm/ajax.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
- .error(message = false) ⇒ Object
-
.success(message = false, data = {}) ⇒ Object
instance methods to go on every controller go here.
Class Method Details
.error(message = false) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/cytoplasm/ajax.rb', line 25 def self.error(=false) output = {"status" => "Error"} output["message"] = if .is_a? String and != "" return output.to_json abort end |
.success(message = false, data = {}) ⇒ Object
instance methods to go on every controller go here
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cytoplasm/ajax.rb', line 15 def self.success(=false,data={}) output = {"status" => "OK"} unless .is_a? String or ==false data = = false end output["message"] = if .is_a? String and !="" data.each {|k,v| output[k] = v if data.key?(k)} unless data.empty? return output.to_json end |