Module: Serega::SeregaPlan::ClassMethods
- Included in:
- Serega::SeregaPlan
- Defined in:
- lib/serega/plan.rb
Overview
SeregaPlan class methods
Instance Method Summary collapse
-
#call(opts) ⇒ SeregaPlan
Constructs plan of attributes that should be serialized.
-
#data_class_for(point_names) ⇒ Class
Returns (and caches) the Data class for the given set of field names.
Instance Method Details
#call(opts) ⇒ SeregaPlan
Constructs plan of attributes that should be serialized.
23 24 25 26 27 28 |
# File 'lib/serega/plan.rb', line 23 def call(opts) max_cache_size = serializer_class.config.max_cached_plans_per_serializer_count return new(nil, opts) if max_cache_size.zero? cached_plan_for(opts, max_cache_size) end |
#data_class_for(point_names) ⇒ Class
Returns (and caches) the Data class for the given set of field names. Uses the Array as cache key so the same Data class is reused across all plan instances with identical fields.
38 39 40 |
# File 'lib/serega/plan.rb', line 38 def data_class_for(point_names) (@data_classes ||= {})[point_names] ||= Data.define(*point_names) end |