tram-policy 0.3.0 → 0.3.1

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: 30e038480a8f83d0dbca7d8f6020c98ed083ec0d
4
- data.tar.gz: e991d7c12a0535892491612d6530fede02527816
3
+ metadata.gz: 7c972ade529b23a0221126e7d486259729314c26
4
+ data.tar.gz: 9f39b73542f528d32fc38db56ddf6122b8abae50
5
5
  SHA512:
6
- metadata.gz: 589f343a85a7e02e64e0cf7322de87ba5bda694a2deaca139b48af6427f266f82fbb25c50d3d1fb42d3fda9e6bbfb0718b339afea05dd252e790fc721c2e398d
7
- data.tar.gz: 04f3bde859bce4d67981c67ef00d356805ff1c6e1a3ac7cf453cd632eb45d526fc64f17c7a45ab27e83b2495ded610299121f3c4af010fda7b6e418ef15cb61c
6
+ metadata.gz: 595fdd5c5980a99bcec80b407780c3f12ba0ac6915130a7f371309cd0d49bcd15d0d64d4d31a84a7a5b25808a7ddba3b64af701aa69f78816b34596f1762ef39
7
+ data.tar.gz: 90b47aff56495a7d15587aff63d673195a4bab761db7d34b12c3e05b3f825d7c7aaf0e3f98d90055a3871a465687a8127b5afd3bd44675ffdcfdf3e3209f3419
@@ -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 = lambda(&block) if 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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "tram-policy"
3
- gem.version = "0.3.0"
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"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tram-policy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Viktor Sokolov (gzigzigzeo)