Class: FunWithJsonApi::SchemaValidators::CheckResourceIsAuthorised
- Inherits:
-
Object
- Object
- FunWithJsonApi::SchemaValidators::CheckResourceIsAuthorised
- Defined in:
- lib/fun_with_json_api/schema_validators/check_resource_is_authorized.rb
Instance Attribute Summary collapse
-
#deserializer ⇒ Object
readonly
Returns the value of attribute deserializer.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#resource_id ⇒ Object
readonly
Returns the value of attribute resource_id.
-
#resource_pointer ⇒ Object
readonly
Returns the value of attribute resource_pointer.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(resource, resource_id, deserializer, resource_pointer: '/data') ⇒ CheckResourceIsAuthorised
constructor
A new instance of CheckResourceIsAuthorised.
- #resource_type ⇒ Object
Constructor Details
#initialize(resource, resource_id, deserializer, resource_pointer: '/data') ⇒ CheckResourceIsAuthorised
Returns a new instance of CheckResourceIsAuthorised.
15 16 17 18 19 20 |
# File 'lib/fun_with_json_api/schema_validators/check_resource_is_authorized.rb', line 15 def initialize(resource, resource_id, deserializer, resource_pointer: '/data') @resource = resource @resource_id = resource_id @deserializer = deserializer @resource_pointer = resource_pointer end |
Instance Attribute Details
#deserializer ⇒ Object (readonly)
Returns the value of attribute deserializer.
12 13 14 |
# File 'lib/fun_with_json_api/schema_validators/check_resource_is_authorized.rb', line 12 def deserializer @deserializer end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
10 11 12 |
# File 'lib/fun_with_json_api/schema_validators/check_resource_is_authorized.rb', line 10 def resource @resource end |
#resource_id ⇒ Object (readonly)
Returns the value of attribute resource_id.
11 12 13 |
# File 'lib/fun_with_json_api/schema_validators/check_resource_is_authorized.rb', line 11 def resource_id @resource_id end |
#resource_pointer ⇒ Object (readonly)
Returns the value of attribute resource_pointer.
13 14 15 |
# File 'lib/fun_with_json_api/schema_validators/check_resource_is_authorized.rb', line 13 def resource_pointer @resource_pointer end |
Class Method Details
.call ⇒ Object
6 7 8 |
# File 'lib/fun_with_json_api/schema_validators/check_resource_is_authorized.rb', line 6 def self.call(...) new(...).call end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fun_with_json_api/schema_validators/check_resource_is_authorized.rb', line 22 def call unless deserializer..call(resource) raise Exceptions::UnauthorizedResource.new( "resource_authorizer method for '#{deserializer.type}' returned a false value", ExceptionPayload.new( pointer: resource_pointer, detail: ) ) end end |
#resource_type ⇒ Object
34 35 36 |
# File 'lib/fun_with_json_api/schema_validators/check_resource_is_authorized.rb', line 34 def resource_type deserializer.type end |