pavlov 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31594240b64696361ea5deeb4a506ba17c5cd1c8
4
- data.tar.gz: 1e8ccb1439a90046a11496bb6fa35c68209f5752
3
+ metadata.gz: 28147e53a9ec3060b50d87d0ffa15929c17f006c
4
+ data.tar.gz: 4f508eb3d010a7f276f68ff269d71ca86e200549
5
5
  SHA512:
6
- metadata.gz: 6ddbe50610a56b8b4d0b52c4875cd3b3b2cd1652fe535fa179143316db2ed1254edce5fa3de0ab3b0c3c3f32f19869939e129d3c7206152ba85aadc032d46307
7
- data.tar.gz: 83bd809253f41acaa8a3c11931950a4d6585ff99151b4919a7138c1d4c92884c5616cdaead48be9c91982c4e10966eb0eea8ec9e52df12545da93d5986490192
6
+ metadata.gz: c9c8cb195850d0e8deb4f8e70c08ba86a587104b66a8f78b920678d0bcf903ebfde8f51dea33e26ce22cd87dda1a7a6a41ad4da5db8090b87d1216ed27385b66
7
+ data.tar.gz: 8bb36fef06d09c8ef8c4a0e91bfb402dee5c95f863aac3aff77200619f69631c1ce371009e120d108556aa693b068a5461f9a1ffc294a09d57088a7e6e94ed77
@@ -5,5 +5,9 @@ module Pavlov
5
5
  module Command
6
6
  extend Pavlov::Concern
7
7
  include Pavlov::Operation
8
+
9
+ def authorized?
10
+ true
11
+ end
8
12
  end
9
13
  end
@@ -1,14 +1,14 @@
1
1
  module Pavlov
2
2
  module Helpers
3
- def interactor name, hash
3
+ def interactor name, hash = {}
4
4
  Pavlov.interactor name, with_pavlov_options(hash)
5
5
  end
6
6
 
7
- def query name, hash
7
+ def query name, hash = {}
8
8
  Pavlov.query name, with_pavlov_options(hash)
9
9
  end
10
10
 
11
- def command name, hash
11
+ def command name, hash = {}
12
12
  Pavlov.command name, with_pavlov_options(hash)
13
13
  end
14
14
 
@@ -16,9 +16,5 @@ module Pavlov
16
16
  @queue ||= :interactor_operations
17
17
  end
18
18
  end
19
-
20
- def authorized?
21
- raise NotImplementedError
22
- end
23
19
  end
24
20
  end
@@ -4,18 +4,24 @@ require 'virtus'
4
4
  require_relative 'access_denied'
5
5
 
6
6
  module Pavlov
7
+ class ValidationError < StandardError
8
+ end
9
+
7
10
  module Operation
8
11
  extend Pavlov::Concern
9
12
  include Pavlov::Helpers
10
13
  include Virtus
11
14
 
12
15
  def validate
13
- return false unless attributes_without_defaults_have_values
14
- if respond_to? :valid?
15
- raise Pavlov::ValidationError, 'an argument is invalid' unless valid?
16
- else
17
- true
18
- end
16
+ return false if attributes_without_defaults_missing_values?
17
+
18
+ raise Pavlov::ValidationError, 'an argument is invalid' unless valid?
19
+
20
+ true
21
+ end
22
+
23
+ def valid?
24
+ true
19
25
  end
20
26
 
21
27
  def call(*args, &block)
@@ -31,14 +37,13 @@ module Pavlov
31
37
  end
32
38
 
33
39
  def check_authorization
34
- raise_unauthorized if respond_to?(:authorized?, true) && !authorized?
40
+ raise_unauthorized unless authorized?
35
41
  end
36
42
 
37
- def attributes_without_defaults_have_values
38
- attributes_without_value = attribute_set.select do |attribute|
43
+ def attributes_without_defaults_missing_values?
44
+ attribute_set.find_index do |attribute|
39
45
  !attribute.options.has_key?(:default) && send(attribute.name).nil?
40
46
  end
41
- attributes_without_value.empty?
42
47
  end
43
48
 
44
49
  module ClassMethods
@@ -5,5 +5,9 @@ module Pavlov
5
5
  module Query
6
6
  extend Pavlov::Concern
7
7
  include Pavlov::Operation
8
+
9
+ def authorized?
10
+ true
11
+ end
8
12
  end
9
13
  end
@@ -2,5 +2,5 @@ module Pavlov
2
2
  # We're doing this because we might write tests that deal
3
3
  # with other versions of bundler and we are unsure how to
4
4
  # handle this better.
5
- VERSION = '0.1.5'
5
+ VERSION = '0.1.6'
6
6
  end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pavlov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
- - marten@veldthuis.com
7
+ - Marten Veldthuis
8
8
  - Mark IJbema
9
9
  - Tom de Vries
10
10
  - Jan Paul Posma
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-08-07 00:00:00.000000000 Z
16
+ date: 2013-08-13 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: virtus
@@ -85,6 +85,20 @@ dependencies:
85
85
  - - '>='
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
+ - !ruby/object:Gem::Dependency
89
+ name: guard-rubocop
90
+ requirement: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ type: :development
96
+ prerelease: false
97
+ version_requirements: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
88
102
  - !ruby/object:Gem::Dependency
89
103
  name: terminal-notifier-guard
90
104
  requirement: !ruby/object:Gem::Requirement
@@ -164,9 +178,6 @@ extra_rdoc_files: []
164
178
  files:
165
179
  - lib/generators/pavlov/install_generator.rb
166
180
  - lib/generators/pavlov/templates/backend/backend.rb
167
- - lib/generators/pavlov/templates/backend/command.rb
168
- - lib/generators/pavlov/templates/backend/interactor.rb
169
- - lib/generators/pavlov/templates/backend/query.rb
170
181
  - lib/pavlov.rb
171
182
  - lib/pavlov/access_denied.rb
172
183
  - lib/pavlov/alpha_compatibility.rb
@@ -1,3 +0,0 @@
1
- class Command
2
- include Pavlov::Operation
3
- end
@@ -1,16 +0,0 @@
1
- class Interactor
2
- include Pavlov::Operation
3
-
4
- # If you want your interactors to be compatible with a backgrounding
5
- # daemon, you can use this base class to add support.
6
- #
7
- # Example for Resque:
8
- #
9
- # def self.perform(*args)
10
- # new(*args).call
11
- # end
12
-
13
- def authorized?
14
- raise NotImplementedError
15
- end
16
- end
@@ -1,3 +0,0 @@
1
- class Query
2
- include Pavlov::Operation
3
- end