bizness 0.6.0 → 0.7.0
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 +4 -4
- data/README.md +3 -3
- data/lib/bizness/policy.rb +9 -3
- data/lib/bizness/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: ac397c6a08c4dd66a3f50a7fe2f5f7611ca50495
|
4
|
+
data.tar.gz: 1f37cf2e9e7a5a0e949f6ed9c9735459ab100405
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 069c309dea1de0c942e95afe8112dda7d8b7dccded8034c2d11144f5e58b6e502495fae69e232eea8fa961ac5c7e6fa4740751f916af5706de60c798ce52c2e5
|
7
|
+
data.tar.gz: 63e95eb213397a8d0908c1fe0232af435b0a9de5d591ed93efdbaec9093d45615dc01b12807e7037442dbbe9020cd2e95901433b9a63e5509bacbeb73c422eb9
|
data/README.md
CHANGED
@@ -93,7 +93,7 @@ We typically wrap this set of criteria in a Policy object, and if the object pas
|
|
93
93
|
Since this is such a common pattern, we created the `Bizness::Policy` module. Here's an example:
|
94
94
|
|
95
95
|
```ruby
|
96
|
-
class StringFormatPolicy
|
96
|
+
class Policies::StringFormatPolicy
|
97
97
|
include Bizness::Policy
|
98
98
|
|
99
99
|
attr_reader :string
|
@@ -113,7 +113,7 @@ class StringFormatPolicy
|
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
116
|
-
policy = StringFormatPolicy.new(string: "abc123")
|
116
|
+
policy = Policies::StringFormatPolicy.new(string: "abc123")
|
117
117
|
policy.successful?
|
118
118
|
#=> false
|
119
119
|
|
@@ -135,7 +135,7 @@ An example I18n translation file looks like this:
|
|
135
135
|
# en.yml
|
136
136
|
en:
|
137
137
|
policies:
|
138
|
-
|
138
|
+
string_format_policy:
|
139
139
|
violations:
|
140
140
|
all_caps: "Characters must be all uppercase"
|
141
141
|
alphanumeric: "String must be alphanumeric"
|
data/lib/bizness/policy.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
#
|
7
7
|
# -- string_format_policy.rb
|
8
8
|
#
|
9
|
-
# class StringFormatPolicy
|
9
|
+
# class Policies::StringFormatPolicy
|
10
10
|
# include Bizness::Policy
|
11
11
|
#
|
12
12
|
# def initialize(string)
|
@@ -58,11 +58,17 @@ module Bizness::Policy
|
|
58
58
|
|
59
59
|
module ClassMethods
|
60
60
|
def violation_message(method)
|
61
|
-
|
62
|
-
message_key = "policies.#{policy}.violations.#{method.to_s.delete("?")}"
|
61
|
+
message_key = "#{__violation_key_prefix__}.#{method.to_s.delete("?")}"
|
63
62
|
I18n.t(message_key)
|
64
63
|
end
|
65
64
|
|
65
|
+
def __violation_key_prefix__
|
66
|
+
@__violation_key_prefix__ ||= begin
|
67
|
+
policy = self.name.gsub(/(.)([A-Z])/, '\1_\2').gsub("::_", ".").downcase
|
68
|
+
"#{policy}.violations"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
66
72
|
def __requirements__
|
67
73
|
@__requirements__ ||= begin
|
68
74
|
private_instance_methods(false).select { |m| m.to_s[/\?$/] }
|
data/lib/bizness/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bizness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ShippingEasy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|