tram-policy 0.3.0 → 0.3.1
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/CHANGELOG.md +6 -0
- data/lib/tram/policy/validator.rb +11 -1
- data/tram-policy.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c972ade529b23a0221126e7d486259729314c26
|
4
|
+
data.tar.gz: 9f39b73542f528d32fc38db56ddf6122b8abae50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 595fdd5c5980a99bcec80b407780c3f12ba0ac6915130a7f371309cd0d49bcd15d0d64d4d31a84a7a5b25808a7ddba3b64af701aa69f78816b34596f1762ef39
|
7
|
+
data.tar.gz: 90b47aff56495a7d15587aff63d673195a4bab761db7d34b12c3e05b3f825d7c7aaf0e3f98d90055a3871a465687a8127b5afd3bd44675ffdcfdf3e3209f3419
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
6
|
|
7
|
+
## [0.3.1] - [2018-01-05]
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
- Convertion of block into lambda in `validate` (nepalez)
|
11
|
+
|
7
12
|
## [0.3.0] - [2018-01-05]
|
8
13
|
|
9
14
|
### Added
|
@@ -137,3 +142,4 @@ This is a first public release (@nepalez, @charlie-wasp, @JewelSam, @sergey-chec
|
|
137
142
|
[0.2.4]: https://github.com/tram-rb/tram-policy/compare/v0.2.3...v0.2.4
|
138
143
|
[0.2.5]: https://github.com/tram-rb/tram-policy/compare/v0.2.4...v0.2.5
|
139
144
|
[0.3.0]: https://github.com/tram-rb/tram-policy/compare/v0.2.5...v0.3.0
|
145
|
+
[0.3.1]: https://github.com/tram-rb/tram-policy/compare/v0.3.0...v0.3.1
|
@@ -15,9 +15,19 @@ class Tram::Policy
|
|
15
15
|
|
16
16
|
def initialize(name, block, stop_on_failure: false)
|
17
17
|
@name = name&.to_sym
|
18
|
-
@block =
|
18
|
+
@block = to_lambda(block)
|
19
19
|
raise "Provide either method name or a block" unless !name ^ !block
|
20
20
|
@stop_on_failure = stop_on_failure
|
21
21
|
end
|
22
|
+
|
23
|
+
def to_lambda(block)
|
24
|
+
return unless block
|
25
|
+
|
26
|
+
unbound = Module.new.module_exec do
|
27
|
+
instance_method define_method(:_, &block)
|
28
|
+
end
|
29
|
+
|
30
|
+
->(&b) { unbound.bind(self == block ? block.receiver : self).call(&b) }
|
31
|
+
end
|
22
32
|
end
|
23
33
|
end
|
data/tram-policy.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = "tram-policy"
|
3
|
-
gem.version = "0.3.
|
3
|
+
gem.version = "0.3.1"
|
4
4
|
gem.author = ["Viktor Sokolov (gzigzigzeo)", "Andrew Kozin (nepalez)"]
|
5
5
|
gem.email = "andrew.kozin@gmail.com"
|
6
6
|
gem.homepage = "https://github.com/tram/tram-policy"
|