Module: Glib::Json::Libs::ClassMethods
- Defined in:
- app/controllers/concerns/glib/json/libs.rb
Instance Method Summary collapse
- #json_libs_force_json_ui ⇒ Object
- #json_libs_init(options) ⇒ Object
- #json_libs_rescue_404 ⇒ Object
-
#json_libs_rescue_500 ⇒ Object
Call this before other rescues.
- #json_libs_rescue_csrf ⇒ Object
- #json_libs_set_locale ⇒ Object
- #json_libs_skip_json_ui(options) ⇒ Object
Instance Method Details
#json_libs_force_json_ui ⇒ Object
127 128 129 |
# File 'app/controllers/concerns/glib/json/libs.rb', line 127 def json_libs_force_json_ui before_action :glib_force_json_ui end |
#json_libs_init(options) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'app/controllers/concerns/glib/json/libs.rb', line 98 def json_libs_init() include Glib::Json::Transformation include Glib::Json::Validation include Glib::Json::Ui include Glib::Json::Traversal include Glib::Json::NewDynamicText before_action do __json_ui_start() end # Note that after_action gets executed in reverse after_action do __json_ui_commit() end after_action :__json_transformation_commit after_action :__json_validate_perform after_action :__json_traversal_perform after_action :__json_traversal_register_dynamic_text end |
#json_libs_rescue_404 ⇒ Object
165 166 167 168 169 170 |
# File 'app/controllers/concerns/glib/json/libs.rb', line 165 def json_libs_rescue_404 # Removed because it doesn't seem to offer anything extra # rescue_from ActiveRecord::RecordNotFound do |exception| # glib_json_handle_404 # end end |
#json_libs_rescue_500 ⇒ Object
Call this before other rescues. Later rescue_from statements will take precedence, so more specific rescues have to be declared later.
159 160 161 162 163 |
# File 'app/controllers/concerns/glib/json/libs.rb', line 159 def json_libs_rescue_500 rescue_from StandardError do |exception| glib_json_handle_500(exception) end end |
#json_libs_rescue_csrf ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'app/controllers/concerns/glib/json/libs.rb', line 140 def json_libs_rescue_csrf rescue_from ActionController::InvalidAuthenticityToken do |exception| sign_out(:user) respond_to do |format| format.json do render json: { onResponse: { action: 'windows/open-v1', url: root_url } } end end end end |
#json_libs_set_locale ⇒ Object
131 132 133 134 135 136 137 138 |
# File 'app/controllers/concerns/glib/json/libs.rb', line 131 def json_libs_set_locale before_action do # Need to explicitly fallback to EN I18n.locale = params[:_locale] || :en rescue I18n.locale = :en end end |
#json_libs_skip_json_ui(options) ⇒ Object
121 122 123 124 125 |
# File 'app/controllers/concerns/glib/json/libs.rb', line 121 def json_libs_skip_json_ui() prepend_before_action do params[:_skip_render] = 'true' end end |