omniperm 0.0.3 → 0.0.4

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
  SHA256:
3
- metadata.gz: 9a95c6e48a800f14e564fc1739f3de6c7523f6da0df3a74a7551cf1bfb1112ae
4
- data.tar.gz: d0cfb2fa102d4364af689f12aa261f03400c340d0f03579463da58625221c252
3
+ metadata.gz: c54a89f4bab72c45f50cff612e24eaba566ab7803fc09c7c021898e5639f5598
4
+ data.tar.gz: 6f81efb19ac42ed400d906eb0a44858c9fccbcbdf5fb6c76c4d5c34192cf3dd1
5
5
  SHA512:
6
- metadata.gz: fc51b8f2f0f9e59d60d74dfa8955f5a26017eff84ded89abd0e39498a731bea21a4c1eb692baec1e89c6fc9e215dc81e33d3a3dfd9adc7b60d84efe8dead6acd
7
- data.tar.gz: 4a9b02818fd4a898918c67ff1c423290bcbbf60bbbbdf8fedc5eed741a53760314fc815aa36ce27fd27ecb1cc0555040b031b14f527a13e907edbbcff9e5244f
6
+ metadata.gz: 1b7f6bfe5e79e679d07f26f548b31b3f813120f59c90a758f60fa2167355b055467e94580822ef6422c26c1468f6ef74f1f039dd1253abd6b4cbc9c57329f754
7
+ data.tar.gz: 6c7a383564f2a33fe135e3f71b22b455623d14c5d63879436cbdbae64f1deec63f6364972cc99bad3aecf3a46a2c580a113cf9ef2b522730dc22c86f03d72fe2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omniperm (0.0.1)
4
+ omniperm (0.0.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -14,8 +14,8 @@ module Omniperm
14
14
  target_methods.reject{|value| [:inject_before_to_methods, :__before_method, :__after_method].include?(value) }.each { |m|
15
15
  # Rename original method
16
16
  target = nil
17
- target = self if instance_methods(false).include?(m.to_sym)
18
- target = self.singleton_class if singleton_methods(false).include?(m.to_sym)
17
+ target = self if instance_methods(false).include?(m.to_sym) # decorate instance methods
18
+ # target = self.singleton_class if singleton_methods(false).include?(m.to_sym) # decorate class methods
19
19
  if target
20
20
  target.send(:alias_method, "__#{m}_original", m)
21
21
  target.define_method m do |*args, **kwargs|
@@ -1,3 +1,3 @@
1
1
  module Omniperm
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.email = %w(samuel@hydrodigit.com)
11
11
  s.date = %q{2020-07-21}
12
12
  s.description = %q{With Omniperm you can centralize your authorization strategies in a YAML file against a configurable context }
13
- s.summary = 'Flexible Authorization for Ruby or Rails'
13
+ s.summary = 'Flexible Authorization for Ruby and Rails'
14
14
  s.homepage = 'https://github.com/3pns/omniperm'
15
15
  s.license = 'MIT'
16
16
  s.files = `git ls-files`.split($/)
@@ -20,6 +20,11 @@ describe Omniperm::Core do
20
20
  assert_equal 42, @service_class_decorated_allowed.buy
21
21
  end
22
22
 
23
+ it 'should not perform authorization for class methods' do
24
+ # @user is pear
25
+ assert_equal 42, Services::ExternalServiceClassDecorated.my_class_method
26
+ end
27
+
23
28
  it 'should perform authorization' do
24
29
  assert_equal false, @service_class_decorated_allowed.bucket
25
30
  end
@@ -5,6 +5,7 @@ require_relative 'helper'
5
5
  describe Omniperm::Core do
6
6
  before do
7
7
  @user = User.new(:pear)
8
+ @user_nanosoft = User.new(:nanosoft)
8
9
  @service = Services::ExternalService.new(@user)
9
10
  @internal_service = Services::InternalService.new(@user)
10
11
  @secret_service = Services::InternalService::SecretService.new(@user)
@@ -16,6 +17,13 @@ describe Omniperm::Core do
16
17
 
17
18
  it 'should properly detect hierarchy and method_name from a class method' do
18
19
  assert_equal 42, Services::ClassService.compute(@user)
20
+ assert_equal false, Services::ClassService.compute(@user_nanosoft)
21
+ end
22
+
23
+ it 'should properly detect instance variables from a class method' do
24
+ skip ("impossible case")
25
+ assert_equal 42, Services::ClassService.compute_instance_variable
26
+ assert_equal false, Services::ClassService.compute_instance_variable
19
27
  end
20
28
 
21
29
  it 'should deny if element has default to true' do
@@ -4,5 +4,10 @@ module Services
4
4
  return false unless service_authorized?(user)
5
5
  return 42
6
6
  end
7
+
8
+ def self.compute_instance_variable
9
+ return false unless service_authorized?
10
+ return 42
11
+ end
7
12
  end
8
13
  end
@@ -20,5 +20,9 @@ module Services
20
20
  def n42
21
21
  return 42
22
22
  end
23
+
24
+ def self.my_class_method
25
+ return 42
26
+ end
23
27
  end
24
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniperm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Bohn
@@ -110,5 +110,5 @@ requirements: []
110
110
  rubygems_version: 3.0.8
111
111
  signing_key:
112
112
  specification_version: 4
113
- summary: Flexible Authorization for Ruby or Rails
113
+ summary: Flexible Authorization for Ruby and Rails
114
114
  test_files: []