pragma-operation 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pragma/operation/validation.rb +11 -1
- data/lib/pragma/operation/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b29615adbb2d556c4e4f2be02095b59bae75fe46
|
4
|
+
data.tar.gz: 621e680a0eebf1fe5e191c734aa68efcf8119328
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2d5b65686b852a0e7b4259fa50e960fd306bb7deabb235f43fd56b2313d34825082470991007c6bf4176e123718d2e28afc874367b106002074dc692df907b1
|
7
|
+
data.tar.gz: 464634670e002f4fe54e48ceda7c810edcb8ac3aac09606d8a1d38471e3abb1f73eabfe36d5fe33b3ad87f63e3b73650cd3c518c070788539d3835562d1cbac1
|
@@ -27,12 +27,15 @@ module Pragma
|
|
27
27
|
|
28
28
|
# Builds the contract for the given resource, using the previous defined contract class.
|
29
29
|
#
|
30
|
+
# If no contract has been defined for this operation, simply returns the resource.
|
31
|
+
#
|
30
32
|
# @param resource [Object]
|
31
33
|
#
|
32
34
|
# @return [Pragma::Contract::Base]
|
33
35
|
#
|
34
36
|
# @see #contract
|
35
37
|
def build_contract(resource)
|
38
|
+
return resource unless contract_klass
|
36
39
|
contract_klass.new(resource)
|
37
40
|
end
|
38
41
|
end
|
@@ -55,6 +58,9 @@ module Pragma
|
|
55
58
|
|
56
59
|
# Validates this operation on the provided contract or resource.
|
57
60
|
#
|
61
|
+
# If no contract has been defined for this operation, tries to call +#validate+ on the
|
62
|
+
# resource. If the resource does not respond to +#validate+, returns true.
|
63
|
+
#
|
58
64
|
# @param validatable [Object|Pragma::Contract::Base] contract or resource
|
59
65
|
#
|
60
66
|
# @return [Boolean] whether the operation is valid
|
@@ -66,7 +72,11 @@ module Pragma
|
|
66
72
|
end
|
67
73
|
# rubocop:enable Metrics/LineLength
|
68
74
|
|
69
|
-
contract.
|
75
|
+
if contract.is_a?(Pragma::Contract::Base)
|
76
|
+
contract.validate(params)
|
77
|
+
else
|
78
|
+
contract.respond_to?(:validate) ? contract.validate : true
|
79
|
+
end
|
70
80
|
end
|
71
81
|
|
72
82
|
# Validates this operation on the provided contract or resource. If the operation is not
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pragma-operation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Desantis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: interactor
|