uuids 4.1.5 → 4.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: 2ff54ff39b28a1294143e1dc4817badd60fcd7c7
4
- data.tar.gz: aa8d3e4492186faa6de6ebb24f7ad6ed96b178f1
3
+ metadata.gz: e60466e84069bbbe17ea18d0cab274efc374b119
4
+ data.tar.gz: 313ba714a9c86ce92e0a6d24a4ba39d91dbee873
5
5
  SHA512:
6
- metadata.gz: 99f7458e54159881f912fd66f483702a0b8870e421a8031d45c7a18e27b9f579cce2e93eeaea4fa8bf4337f2fabb1a965a3b5ade19c9e291b1507a0e10e7deaa
7
- data.tar.gz: b0227c73c54278136b57c46f39e3a1df961557e41c6a0ac41faa480f00f1dbdd2b9b3ae9c234b038a6b61ca1bd2c188c8740b0890cacb4e439a2192c8a05c464
6
+ metadata.gz: b858909ab9bd547df281aebca36d15331de2194902ac2ef43dd21d0500a1bbb065ce34d1ae67756e9051506839adf5b1ba5b41226ef947a66c21f22ceef8db78
7
+ data.tar.gz: b74a87db3c878373a5ee13849ff38b7c147593ebf23681bdbabcf21ec783555d69418fb4275ccbaacb3bae9915989c2118823971bc5caf57c28c76c7bd91812a
data/README.rdoc CHANGED
@@ -149,10 +149,8 @@ The module also contains the service object +Add+:
149
149
  Depending on the result of creation, the listener will receive either the
150
150
  <tt>:created, uuid, messages</tt> or <tt>:error, messages</tt> notification.
151
151
 
152
- The service doesn't know what the record is. In the success message it
153
- will be referred as the record "with id: %{id}".
154
- To provide more concise messaging, the service should be reloaded with a
155
- new <tt>name</tt> method.
152
+ The service doesn't know what the record is. To provide more concise messaging,
153
+ the service should be reloaded with a new <tt>name</tt> method.
156
154
 
157
155
  module Users
158
156
  module Services
data/app/services/add.rb CHANGED
@@ -21,6 +21,10 @@ module Uuids
21
21
  # )
22
22
  # service.subscribe some_listener
23
23
  # service.run
24
+ #
25
+ # @change Creates the uuid assigned to the record.
26
+ # @publish created(uuid,messages) when the uuid has been created.
27
+ # @publish error(messages) when the uuid cannot be created.
24
28
  class Add < Hexx::Service
25
29
 
26
30
  # @!scope class
@@ -44,11 +48,10 @@ module Uuids
44
48
 
45
49
  # Runs the service and publishes its results.
46
50
  # @example (see Uuids::Services::Add)
47
- # @change Creates the uuid assigned to the record.
48
- # @publish created(uuid,messages) when the uuid has been created.
49
- # @publish error(messages) when the uuid cannot be created.
51
+ # @change (see Uuids::Services::Add)
52
+ # @publish (see Uuids::Services::Add)
50
53
  def run
51
- escape { create_uuid }
54
+ run!
52
55
  rescue => err
53
56
  publish :error, err.messages
54
57
  else
@@ -59,9 +62,11 @@ module Uuids
59
62
 
60
63
  attr_reader :uuid
61
64
 
62
- def create_uuid
63
- @uuid = Models::Uuid.create! record: record, value: value
64
- add_message "success", :created, uuid: uuid, record: name
65
+ def run!
66
+ escape do
67
+ @uuid = Models::Uuid.create! record: record, value: value
68
+ add_message "success", :created, uuid: uuid, record: name
69
+ end
65
70
  end
66
71
 
67
72
  def name
@@ -54,14 +54,14 @@ module Uuids
54
54
  # @api hide
55
55
  # Constructs the object and adds the attribute.
56
56
  # @example (see Uuids::Base::BelongsTo)
57
- # @params [ActiveRecord::Base] klass The model to add attribute to.
57
+ # @param [ActiveRecord::Base] klass The model to add attribute to.
58
58
  # Should have a corresponding column for reference by uuid.
59
- # @params [String, Symbol] name The name of the attribute to be added.
60
- # @params [ActiveRecord::Base] model The model to be referred by uuid.
59
+ # @param [String, Symbol] name The name of the attribute to be added.
60
+ # @param [ActiveRecord::Base] model The model to be referred by uuid.
61
61
  # Should include the <tt>Uuids::Base</tt> module.
62
62
  # @raise (see Uuids::Base::BelongsTo#add)
63
- def self.add(*args)
64
- new(*args).add
63
+ def self.add(klass, name, model)
64
+ new(klass, name, model).add
65
65
  end
66
66
 
67
67
  # @api hide
data/lib/uuids/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Uuids
2
2
 
3
3
  # Current release.
4
- VERSION = "4.1.5"
4
+ VERSION = "4.1.6"
5
5
  end
@@ -30,12 +30,12 @@ ActiveRecord::Schema.define(version: 20151215182355) do
30
30
  end
31
31
 
32
32
  create_table "uuids_uuids", force: :cascade do |t|
33
- t.string "value", limit: 36, null: false
34
- t.integer "record_id", null: false
35
- t.string "record_type", limit: 255, null: false
33
+ t.string "value", limit: 36, null: false
34
+ t.integer "record_id", null: false
35
+ t.string "record_type", null: false
36
36
  end
37
37
 
38
- add_index "uuids_uuids", ["record_id", "record_type"], name: "index_uuids_uuids_on_record_id_and_record_type"
38
+ add_index "uuids_uuids", ["record_type", "record_id"], name: "index_uuids_uuids_on_record_type_and_record_id"
39
39
  add_index "uuids_uuids", ["value"], name: "index_uuids_uuids_on_value", unique: true
40
40
 
41
41
  end
Binary file
@@ -2,7 +2,7 @@ require_relative "capture_stdout"
2
2
 
3
3
  # Path to the `tmp/sandbox`.
4
4
  def sandbox
5
- @sandbox ||= File.expand_path "../../../../../tmp/sandbox", __FILE__
5
+ @sandbox ||= File.expand_path "../../../../sandbox", __FILE__
6
6
  end
7
7
 
8
8
  # Clears `tmp/sandbox`.
@@ -12,8 +12,7 @@ module Uuids::Services
12
12
  let!(:params) do
13
13
  {
14
14
  "record" => record,
15
- "value" => SecureRandom.uuid,
16
- "wrong" => "wrong"
15
+ "value" => SecureRandom.uuid
17
16
  }
18
17
  end
19
18
 
@@ -25,28 +24,13 @@ module Uuids::Services
25
24
  service
26
25
  end
27
26
 
28
- describe ".new" do
29
-
30
- it "sets #record" do
31
- expect(subject.record).to eq params["record"]
32
- end
33
-
34
- it "sets #value" do
35
- expect(subject.value).to eq params["value"]
36
- end
37
-
38
- it "whitelists params" do
39
- expect(subject.params).to eq params.slice("record", "value")
40
- end
41
- end
42
-
43
27
  describe "#run" do
44
28
 
45
29
  context "with valid params" do
46
30
 
47
31
  it "adds a uuid to the record" do
48
32
  expect { subject.run }.to change { uuids_class.count }.by 1
49
- expect(uuids_class.last).to correspond_to subject.params
33
+ expect(uuids_class.last).to correspond_to params
50
34
  end
51
35
 
52
36
  it "publishes :created" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uuids
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.5
4
+ version: 4.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kozin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-22 00:00:00.000000000 Z
11
+ date: 2014-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hexx-active_record
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.1'
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.1'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: coveralls
29
29
  requirement: !ruby/object:Gem::Requirement