mongoid_ability 2.0.2 → 2.0.3

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: cccd3fd24f60f4b34354c4ded9ad957fc4fb70137fc42d38ec38e74b84fa8904
4
- data.tar.gz: 55950648a4435d08485617178431cc60326e38b2f83c094d20909c11d9f0a1ed
3
+ metadata.gz: bbab2a3e7461bdec8e23c4d9b1027cac1575efed88174a704c4178b1e666c442
4
+ data.tar.gz: 03370daedb464860849fb9fab3144d6b718cad2a24044ea341deb7179d5879d5
5
5
  SHA512:
6
- metadata.gz: a99121ecb016a80bb5cbc94ca5ae325dcc7303ece2f419f92bdb83380cd4bf970baefde9a1c99aa433c737c7ad76ad5399df14d2bdd3190190856a4b82d5f2d1
7
- data.tar.gz: 3a5297b943f849c774bf8162b7a3bbf796df4ce676d49c5f30f83e46d9ac9fb989e97553a547b86aa8b239a534b817c2db96f8d5899185c56d9474f4aa891d6b
6
+ metadata.gz: 451a7e6d02d26419a0629584bf7a1627e2b58c8688db01f5b9bdfdeebec693b77d09ad1a46c5b40272fb31245e4e80476fb81b87606d40940a0b6d62aa0802b7
7
+ data.tar.gz: '084a93016fbc7b4ec745502bbf98addb04754b7081738262e68682ac7ead9026b27c3b9439c81d86b895e3a1a9d603f58397ec5a61c6c23cdcb9240c890dab4e'
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.0.3
4
+
5
+ * memoize `model_adapter` for better performance
6
+
3
7
  ## 2.0.2
4
8
 
5
9
  * upgrade to `CanCanCan` 2.2
@@ -67,14 +67,19 @@ module MongoidAbility
67
67
  end
68
68
 
69
69
  def model_adapter(model_class, action, options = {})
70
- adapter_class = CanCan::ModelAdapters::AbstractAdapter.adapter_class(model_class)
71
- # include all rules that apply for descendants as well
72
- # so the adapter can exclude include subclasses from critieria
73
- rules = ([model_class] + model_class.descendants).inject([]) do |res, cls|
74
- res += relevant_rules_for_query(action, cls)
75
- res.uniq
70
+ @model_adapter ||= {}
71
+ @model_adapter[model_class] ||= {}
72
+ @model_adapter[model_class][action] ||= {}
73
+ @model_adapter[model_class][action][options] ||= begin
74
+ adapter_class = CanCan::ModelAdapters::AbstractAdapter.adapter_class(model_class)
75
+ # include all rules that apply for descendants as well
76
+ # so the adapter can exclude include subclasses from critieria
77
+ rules = ([model_class] + model_class.descendants).inject([]) do |res, cls|
78
+ res += relevant_rules_for_query(action, cls)
79
+ res.uniq
80
+ end
81
+ adapter_class.new(model_class, rules, options)
76
82
  end
77
- adapter_class.new(model_class, rules, options)
78
83
  end
79
84
 
80
85
  private
@@ -1,3 +1,3 @@
1
1
  module MongoidAbility
2
- VERSION = '2.0.2'.freeze
2
+ VERSION = '2.0.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_ability
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-14 00:00:00.000000000 Z
11
+ date: 2018-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cancancan