bizness 0.6.0 → 0.7.0

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: 6be2ccb0ce9564adc8d96d444dc6be4418c1db7c
4
- data.tar.gz: 0d25e8548ffb56eb352e66b974630bc5851a48e3
3
+ metadata.gz: ac397c6a08c4dd66a3f50a7fe2f5f7611ca50495
4
+ data.tar.gz: 1f37cf2e9e7a5a0e949f6ed9c9735459ab100405
5
5
  SHA512:
6
- metadata.gz: a634804e9296927f0d8e339845d793178ee708e86b631a389178f2c7f03cddcf77b742c177451080e1324fbbfd8280df8e7d2f8501bb9ac39ae06f3d6e146d83
7
- data.tar.gz: 25b120fc67cf176b01b002db976eda1c3e254030d75d14fa3d1ba1a38b74e0585be33cebef77524f4d6eea84b4a95bb41f1a5a451e02b659e578bf86a5a79747
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
- mock_policy:
138
+ string_format_policy:
139
139
  violations:
140
140
  all_caps: "Characters must be all uppercase"
141
141
  alphanumeric: "String must be alphanumeric"
@@ -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
- policy = self.name.gsub(/(.)([A-Z])/,'\1_\2').downcase
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[/\?$/] }
@@ -1,3 +1,3 @@
1
1
  module Bizness
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
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.6.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-01 00:00:00.000000000 Z
11
+ date: 2015-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord