break_dance 0.9.0 → 0.9.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: 0d2eded9292f501fe9c7c4cd28220706c696a3bb
4
- data.tar.gz: 9c818de083853d12006836607e5f0265b2a92875
3
+ metadata.gz: 1d878106aa1c8301266ea7fd4b41bc0892998b89
4
+ data.tar.gz: 20736a7bb31150ea650b60feb868d5c7b4bcecb9
5
5
  SHA512:
6
- metadata.gz: 570bb6582af6055b94bfec493269f45ab06773f36ae98aa5e1bfbe57f02b3aa7a5ef9f60f2020fdc6c45361a5d2eb3173b55e7152d32d0bd154e5081b92e0b3d
7
- data.tar.gz: 7e7264a95d88a99142cbc77f4405180ba2d9c96e3aa69ad46bc553a6b855e5343c3c8eeab945cba26c37044442d7de30c1c17ca7703426d0cc992344286fcd4d
6
+ metadata.gz: 8dbb849e71f88b0f3b17aa46cb60c9725f47c7fb5d485eb0517d61c2139d5d2b5226668b5de304fe8930b6b4d4137d2f315f9f51896ebc6cdae3bf3d4a388749
7
+ data.tar.gz: c9069098f7e51dfd1ca65fe50ab52d6c0f6c84b4403427fb16c7197ec7e8e7d479502ff2924b43151016a7e4a7ae10be4e7df2c4bdf1113c3b6afb8683a78768
@@ -4,9 +4,11 @@ module BreakDance
4
4
 
5
5
  class_methods do
6
6
  # We cannot use alias_method here, because "super" of the aliased method is the "super" of the original method.
7
+ # ToDo: This caller(1,1).include? thing is baaaaaad. Probably the whole concept should be reconsidered again. I can probably and up it just a default scopes
8
+ # and new method "apply break_dance" to explicitly apply. Or I can just override the finder methods like where, find, take, etc.
7
9
  %w(default_scoped unscoped).each do |method_name|
8
10
  define_method method_name do |unsecured: false, &block|
9
- if RequestLocals.store[:break_dance_enabled] && !unsecured
11
+ if RequestLocals.store[:break_dance_enabled] && !unsecured && !caller(1,1).first.include?(':in `_update_record\'')
10
12
  policy = RequestLocals.store[:break_dance_policy]
11
13
 
12
14
  raise PolicyNotFound.new('BreakDance::Policy is not defined. By design BreakDance requires all models to be scoped.') unless policy.is_a?(BreakDance::Policy)
@@ -54,4 +56,25 @@ module ActiveRecord
54
56
 
55
57
  end
56
58
  end
59
+
60
+ # This is not working. If we start in that direction we can end up with a bunch of patching to just undo what we did above.
61
+ # module Persistence
62
+ # def _update_record(attribute_names = self.attribute_names)
63
+ # attributes_values = arel_attributes_with_values_for_update(attribute_names)
64
+ # if attributes_values.empty?
65
+ # rows_affected = 0
66
+ # @_trigger_update_callback = true
67
+ # else
68
+ # rows_affected = self.class.unsecured_unscoped!._update_record attributes_values, id, id_in_database
69
+ # @_trigger_update_callback = rows_affected > 0
70
+ # end
71
+ #
72
+ # yield(self) if block_given?
73
+ #
74
+ # rows_affected
75
+ # end
76
+ #
77
+ # end
78
+
79
+
57
80
  end
@@ -1,3 +1,3 @@
1
1
  module BreakDance
2
- VERSION = '0.9.0'
2
+ VERSION = '0.9.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: break_dance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zlatko Zahariev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-28 00:00:00.000000000 Z
11
+ date: 2017-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails