kono_utils_bootstrap_view4 0.3 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5bdd8ddcea66e345b2ed25e26aabf373277f7334c6b7edaf82ba05ab71011d1
4
- data.tar.gz: 2410cbf0a6d46ded157eb57f5970ee53bbc263451ea17a54a947a528c94dad62
3
+ metadata.gz: aa0a2f1125771c5f72660fb327ededb8c2262eb4f036618f3bafdd78a3e54c5c
4
+ data.tar.gz: 56914dcf749aa2959aca53d809c2045b37cc0c0cc432047c351b48c689fdd7de
5
5
  SHA512:
6
- metadata.gz: c72f29263f5e92614fca30a725899d3ed8e6286770c0efe9695ef2e53270ea6f9262dcc0ee65ab623b338799fa0c4000db79e0f7abf6b75f4959053ab110f423
7
- data.tar.gz: 2181dc4a1ac3fd4d3cfc83ced1f6400a20478ea911074b704f6f07d8b6fac2b3543134460ff14bf6b87d2e9657c5828970546cf798efe3dbf13fcd049e659137
6
+ metadata.gz: f4318dbe3a8f1ef499fdc36748a446a6ef947a220151da1800542975c4894cf093f8178abf04d6b9c8d3e893ea45bb2765f894a0a11c25bfb97ac08f536db0d4
7
+ data.tar.gz: aadf01fb29d8bf9c424dd5296272e5926bb9e078ad966526c00fa33cf929e28019df2dcc0c4a1710b2d0b25a17dca47b1a06ace59a9d6de76a38a183493391b6
@@ -4,6 +4,11 @@ module KonoUtils
4
4
  module Index # namespace
5
5
  class RowButtons < Base # class
6
6
 
7
+ ##
8
+ # Restituisce la policy per la riga, non viene instanziata più volte per oggetto
9
+ def cached_policy
10
+ @_cached_policy ||= policy(model)
11
+ end
7
12
  end
8
13
  end
9
14
  end
@@ -1,3 +1,3 @@
1
- <%= concept("cell/buttons/show", model) if policy(model).show? %>
2
- <%= concept("cell/buttons/edit", model) if policy(model).edit? %>
3
- <%= concept("cell/buttons/delete", model) if policy(model).destroy? %>
1
+ <%= concept("cell/buttons/show", model) if cached_policy.show? %>
2
+ <%= concept("cell/buttons/edit", model) if cached_policy.edit? %>
3
+ <%= concept("cell/buttons/delete", model) if cached_policy.destroy? %>
@@ -14,6 +14,7 @@ module KonoUtilsBootstrapView4
14
14
  autoload :Engine
15
15
  autoload :PaginateProxer
16
16
  autoload :SearchFormBuilder
17
+ autoload :ConceptCacher
17
18
  autoload :VERSION
18
19
 
19
20
  class << self
@@ -14,26 +14,16 @@ module KonoUtilsBootstrapView4
14
14
  end
15
15
 
16
16
  def concept_ns(view)
17
- @_memo_concept ||= {}
18
17
  ns = "#{tableize(self.name)}/#{view}"
19
-
20
- unless @_memo_concept.key?(ns)
18
+ KonoUtilsBootstrapView4.configuration.concept_cacher.get(ns) do |cache|
21
19
  if safe_constantize(ns.camelize)
22
20
  KonoUtilsBootstrapView4.configuration.logger.info { "TROVATA CLASSE PER : #{ns.camelize} --->>>" }
23
- @_memo_concept[ns] = ns
21
+ cache.store(ns, ns)
24
22
  else
25
- @_memo_concept[ns] = false
23
+ KonoUtilsBootstrapView4.configuration.logger.debug { "CLASSE OVERRIDE NON TROVATA PER : #{ns.camelize}" }
24
+ cache.store(ns, "kono_utils/object/#{view}")
26
25
  end
27
26
  end
28
-
29
- if @_memo_concept[ns]
30
- return @_memo_concept[ns]
31
- else
32
- KonoUtilsBootstrapView4.configuration.logger.debug { "CLASSE OVERRIDE NON TROVATA PER : #{ns.camelize}" }
33
-
34
- "kono_utils/object/#{view}"
35
- end
36
-
37
27
  end
38
28
 
39
29
  ##
@@ -0,0 +1,38 @@
1
+ module KonoUtilsBootstrapView4
2
+ ##
3
+ # PORO per l'esecuzione della cache a livello di istanza applicazione dei nomi di classe da utilizzare per i vari
4
+ # componenti dei modelli
5
+ class ConceptCacher
6
+ #@return [Hash]
7
+ attr_reader :_cache
8
+
9
+ def initialize
10
+ @_cache = {}
11
+ end
12
+
13
+ def clear
14
+ Rails.logger.debug {"PULIZIA CACHE"}
15
+ @_cache = {}
16
+ end
17
+
18
+ ##
19
+ # Ritorna il valore cachato, se non è presente, allora verrà dato in pasto allo yield l'istanza di cache, e sarà
20
+ # chi la utilizzerà che si occuperà di salvare o meno il dato richiamato il metodo store passando il relativo valore da
21
+ # salvare
22
+ # @param [String] key
23
+ # @return [Object] Cached result
24
+ # @yieldparam [KonoUtilsBootstrapView4::ConceptCacher]
25
+ def get(key)
26
+ return @_cache[key] if @_cache.key?(key)
27
+ yield(self)
28
+ @_cache[key]
29
+ end
30
+
31
+ ##
32
+ # Store del valore
33
+ def store(key, value)
34
+ @_cache[key] = value
35
+ end
36
+
37
+ end
38
+ end
@@ -10,8 +10,15 @@ class KonoUtilsBootstrapView4::Configuration
10
10
  #@return [Boolean]
11
11
  attr_accessor :cell_metrics
12
12
 
13
+ ##
14
+ # Cache delle classi del concept
15
+ # Nell'inizializzazione di rails aggiungiamo un ascoltatore alla cartella standard dei concepts per
16
+ # controllare se i files sono stati modificati, nel caso puliamo completamente la cartella
17
+ attr_reader :concept_cacher
18
+
13
19
  def initialize
14
20
  @moment_js_locales = I18n.available_locales
21
+ @concept_cacher = KonoUtilsBootstrapView4::ConceptCacher.new
15
22
 
16
23
  @cell_metrics = false
17
24
  # inizializzo logger, come quello che mi verrebbe passato
@@ -44,6 +44,11 @@ module KonoUtilsBootstrapView4
44
44
  end
45
45
  end
46
46
 
47
+ initializer 'kono_utils_bootstrap_view4.configure_auto_clear_concept_cache', :group => :all do |app|
48
+ app.reloader.to_prepare do
49
+ KonoUtilsBootstrapView4.configuration.concept_cacher.clear
50
+ end
51
+ end
47
52
  ##
48
53
  # Abbiamo rimosso possibili JS, lasciamo per documentazione
49
54
  initializer 'kono_utils_bootstrap_view4.append_cell_assets', :group => :all do |app|
@@ -1,3 +1,3 @@
1
1
  module KonoUtilsBootstrapView4
2
- VERSION = '0.3'
2
+ VERSION = '0.3.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kono_utils_bootstrap_view4
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marino Bonetti
@@ -350,6 +350,7 @@ files:
350
350
  - lib/kono_utils_bootstrap_view4/application_icon_helper.rb
351
351
  - lib/kono_utils_bootstrap_view4/base_class_concept_ns.rb
352
352
  - lib/kono_utils_bootstrap_view4/base_search.rb
353
+ - lib/kono_utils_bootstrap_view4/concept_cacher.rb
353
354
  - lib/kono_utils_bootstrap_view4/configuration.rb
354
355
  - lib/kono_utils_bootstrap_view4/editable_field.rb
355
356
  - lib/kono_utils_bootstrap_view4/engine.rb