bizness 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/bizness/policy.rb +5 -3
- data/lib/bizness/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5763645a9f422b6ffffcd1c7d2479e5e90d954ee
|
4
|
+
data.tar.gz: 544d347d96ca56f02295460f2a81b66450b03bfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47de010ec86cd7ab359631bff52169b20de0a43418f066947b555b0bc1e726b3913f42390a486d54d9358fc200241e2c643b8d8311ecf80843b99c28dfa96590
|
7
|
+
data.tar.gz: 385b68bd06eeaacba49548a8d51caad440b23eda8892f6d7b7aff251d95e58389c72804f3d339dfd326fa089605dd97135be2bf4c3a6ff801be16e6f89b963a8
|
data/README.md
CHANGED
@@ -124,11 +124,11 @@ policy.violations
|
|
124
124
|
#=> ["String must be alphanumeric", "Characters must be all uppercase"]
|
125
125
|
```
|
126
126
|
|
127
|
-
By including the module, the object gets the `obeyed?` method which does the following when called:
|
127
|
+
By including the module, the object gets the `violated?` (and `obeyed?`) method which does the following when called:
|
128
128
|
|
129
129
|
1. Introspects all private predicate methods (methods that end with a question mark) and executes them
|
130
130
|
2. If the method returns false, it looks for a translation in an I18n YAML file
|
131
|
-
3. It composes an
|
131
|
+
3. It composes an I18n key using the policy's class and method name (without the question mark). For example: `policies.mock_policy.violations.all_caps`
|
132
132
|
4. It adds the result of the translation to the list of `violations`
|
133
133
|
5. It returns false if any violations are found
|
134
134
|
|
data/lib/bizness/policy.rb
CHANGED
@@ -64,6 +64,10 @@ module Bizness::Policy
|
|
64
64
|
end
|
65
65
|
|
66
66
|
module ClassMethods
|
67
|
+
def policy_enforces(*method_names)
|
68
|
+
@__requirements__ = method_names
|
69
|
+
end
|
70
|
+
|
67
71
|
def violation_message(method)
|
68
72
|
message_key = "#{__violation_key_prefix__}.#{method.to_s.delete("?")}"
|
69
73
|
I18n.t(message_key)
|
@@ -77,9 +81,7 @@ module Bizness::Policy
|
|
77
81
|
end
|
78
82
|
|
79
83
|
def __requirements__
|
80
|
-
@__requirements__
|
81
|
-
private_instance_methods(false).select { |m| m.to_s[/\?$/] }
|
82
|
-
end
|
84
|
+
@__requirements__
|
83
85
|
end
|
84
86
|
end
|
85
87
|
|
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.9.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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
156
|
rubyforge_project:
|
157
|
-
rubygems_version: 2.4.
|
157
|
+
rubygems_version: 2.4.6
|
158
158
|
signing_key:
|
159
159
|
specification_version: 4
|
160
160
|
summary: Get your bizness right and organize your business logic into operations.
|