ddd_domain 1.4.13 → 1.4.14

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
  SHA256:
3
- metadata.gz: 36b2ff382125b70760e504caef88157a6878e80c22827c283354230a46e2f4b6
4
- data.tar.gz: c01b1b3973a9124ea0dc990baa828fb37f95bd84db917caed490e31964a5cf78
3
+ metadata.gz: f1cbf7f4760d30a449a6f3db4943df0e7e1ae534cd3e7cd748448ed5bf6203fb
4
+ data.tar.gz: 2f7fe28402b343cebd64600f12e67e594ed333c4ff39a5ff8fa3c73349d4755f
5
5
  SHA512:
6
- metadata.gz: 6dabb3c54a7e33beda381d17bdc43aa58c981c3d930824cc664a08b369edabb0b16c5b33a0081083f3e2c142925f8d4fed8ba68ced2eb17f68d0513c754b3875
7
- data.tar.gz: 7378ea5fb89fb4a80ba5043fbfef70d0e293adb0439bbe17a133a59bc5b7b6a094c12f66d184b14d9099b0b340a349b3ddb6a3246ac24fa1e74cde4d62118608
6
+ metadata.gz: af1e3f9c2bd966fa2c7c9f07b5026ee5554fe6d7fd7464032d792de82a72e3d7a26cba2bce9a8698f8a14bc445289ea96746d4b9addb7670852e66e2be2979f7
7
+ data.tar.gz: bdaff4e02eb970ad90796394f5b292031a87a8a7db04b95f5914c5e1d44ae285dfaadf9f7097f21097c8651d64e0de053a6ab069e4f4c6437a8c273fcf669f99
@@ -10,6 +10,11 @@ module DddDomain
10
10
  # - exception: the original exception behind an unexpected failure (for
11
11
  # logging and diagnostics; do not branch business logic on it)
12
12
  #
13
+ # The exception is never exposed by #to_h (and therefore by #as_json /
14
+ # #to_json under ActiveSupport), and #inspect shows only its class, so that
15
+ # internal error details do not leak into responses or logs by accident.
16
+ # Read #exception explicitly when you need it.
17
+ #
13
18
  # @example
14
19
  # result = DddDomain::DomainResult.failure("The order is already shipped")
15
20
  # result.failure? # => true
@@ -36,5 +41,22 @@ module DddDomain
36
41
  def failure?
37
42
  !success
38
43
  end
44
+
45
+ # @return [Hash] the attributes except +exception+
46
+ def to_h(&block)
47
+ hash = { success: success, message: message }
48
+ block ? hash.to_h(&block) : hash
49
+ end
50
+
51
+ # @return [String] a representation that shows only the class of +exception+
52
+ def inspect
53
+ exception_text = exception.nil? ? "nil" : "#<#{exception.class}>"
54
+ "#<data #{self.class} success=#{success.inspect}, message=#{message.inspect}, exception=#{exception_text}>"
55
+ end
56
+ alias_method :to_s, :inspect
57
+
58
+ def pretty_print(q)
59
+ q.text(inspect)
60
+ end
39
61
  end
40
62
  end
@@ -1,3 +1,3 @@
1
1
  module DddDomain
2
- VERSION = "1.4.13"
2
+ VERSION = "1.4.14"
3
3
  end
@@ -1,7 +1,14 @@
1
1
  class DomainsGenerator < Rails::Generators::NamedBase
2
2
  source_root File.expand_path('../templates', __FILE__)
3
3
 
4
+ VALID_NAME = /\A[a-z][a-z0-9_]*\z/
5
+
4
6
  def create_initializer_file
7
+ unless file_name.match?(VALID_NAME)
8
+ raise Thor::Error, "Invalid domain name: #{name.inspect}. " \
9
+ "Use letters, digits and underscores, starting with a letter (e.g. order, user_account)."
10
+ end
11
+
5
12
  empty_directory "app/domains/#{file_name}"
6
13
  create_file "app/domains/#{file_name}/.keep"
7
14
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddd_domain
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.13
4
+ version: 1.4.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - FUNABARA Masao
@@ -44,7 +44,11 @@ files:
44
44
  homepage: https://github.com/masoo/ddd_domain
45
45
  licenses:
46
46
  - MIT
47
- metadata: {}
47
+ metadata:
48
+ homepage_uri: https://github.com/masoo/ddd_domain
49
+ source_code_uri: https://github.com/masoo/ddd_domain
50
+ bug_tracker_uri: https://github.com/masoo/ddd_domain/issues
51
+ rubygems_mfa_required: 'true'
48
52
  rdoc_options: []
49
53
  require_paths:
50
54
  - lib