Module: JsonApiResponders
- Defined in:
- lib/json_api_responders.rb,
lib/json_api_responders/config.rb,
lib/json_api_responders/errors.rb,
lib/json_api_responders/version.rb,
lib/json_api_responders/responder.rb,
lib/json_api_responders/responder/actions.rb,
lib/json_api_responders/responder/sanitizers.rb
Defined Under Namespace
Modules: Errors
Classes: Config, Responder
Constant Summary
collapse
- MAJOR =
2
- MINOR =
7
- PATCH =
1
- VERSION =
[MAJOR, MINOR, PATCH].join('.').freeze
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Class Attribute Details
.config ⇒ Object
17
18
19
|
# File 'lib/json_api_responders.rb', line 17
def self.config
@config ||= JsonApiResponders::Config.new
end
|
Class Method Details
13
14
15
|
# File 'lib/json_api_responders.rb', line 13
def self.configure
yield(config) if block_given?
end
|
.included(base) ⇒ Object
21
22
23
24
|
# File 'lib/json_api_responders.rb', line 21
def self.included(base)
base.rescue_from ActiveRecord::RecordNotFound, with: :record_not_found!
base.rescue_from ActionController::ParameterMissing, with: :parameter_missing!
end
|
Instance Method Details
#respond_with(resource, options = {}) ⇒ Object
26
27
28
29
30
|
# File 'lib/json_api_responders.rb', line 26
def respond_with(resource, options = {})
options = { params: params }.merge(options)
JsonApiResponders.config.check_required_options(options)
Responder.new(self, resource, **options).respond!
end
|
#respond_with_error(status, detail = nil) ⇒ Object
32
33
34
|
# File 'lib/json_api_responders.rb', line 32
def respond_with_error(status, detail = nil)
Responder.new(self, nil, on_error: { status: status, detail: detail }).respond_error
end
|