pragma-operation 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 448af287bc5592b8f11475e11c5363bf742ed9ba
4
- data.tar.gz: 63765f85f69ce238b612192b195bba8f9d0aad02
3
+ metadata.gz: b29615adbb2d556c4e4f2be02095b59bae75fe46
4
+ data.tar.gz: 621e680a0eebf1fe5e191c734aa68efcf8119328
5
5
  SHA512:
6
- metadata.gz: '018c231d13a8afec86fc5bdfe52f73bda8fba96ea9725765307c7a5869a67fd00d909137a69b2db44b5fd8cf49ba6841f4b2b5f301ff5466bbea92cf57070c62'
7
- data.tar.gz: d57d5deb6f608e458d8a385e39f754fb044041524864a7ba9ac2de30e2a8cebb471cdc6fb6bd06fc03637a46ff1e5eb13fdaffc9bb553c99164ce09bd1320669
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.validate(params)
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Pragma
3
3
  module Operation
4
- VERSION = '1.2.1'
4
+ VERSION = '1.2.2'
5
5
  end
6
6
  end
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.1
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-29 00:00:00.000000000 Z
11
+ date: 2016-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: interactor