Module: Serega::SeregaPlan::InstanceMethods

Included in:
Serega::SeregaPlan
Defined in:
lib/serega/plan.rb

Overview

SeregaPlan instance methods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#has_batch_pointsArray<SeregaPlanPoint> (readonly)

Shows if plan includes batch points



70
71
72
# File 'lib/serega/plan.rb', line 70

def has_batch_points
  @has_batch_points
end

#parent_plan_pointSeregaPlanPoint? (readonly)

Parent plan point



62
63
64
# File 'lib/serega/plan.rb', line 62

def parent_plan_point
  @parent_plan_point
end

#pointsArray<SeregaPlanPoint> (readonly)

Serialization points



66
67
68
# File 'lib/serega/plan.rb', line 66

def points
  @points
end

Instance Method Details

#initialize(parent_plan_point, modifiers) ⇒ SeregaPlan

Instantiate new serialization plan

Patched by

- depth_limit plugin, which checks depth limit is not exceeded when adding new plan

Options Hash (modifiers):

  • :only (Hash)

    The only attributes to serialize

  • :except (Hash)

    Attributes to hide

  • :with (Hash)

    Hidden attributes to serialize additionally



86
87
88
89
90
# File 'lib/serega/plan.rb', line 86

def initialize(parent_plan_point, modifiers)
  @has_batch_points = false # should be before assigning points, generated points can change this attribute
  @parent_plan_point = parent_plan_point
  @points = attributes_points(modifiers)
end

#mark_as_has_batch_pointsObject

Marks current plan and top-level plans as ‘has_batch_points` It is needed to initialize Batch Attribute Loaders when serialization starts



103
104
105
106
107
108
# File 'lib/serega/plan.rb', line 103

def mark_as_has_batch_points
  return if has_batch_points

  @has_batch_points = true
  parent_plan_point.plan.mark_as_has_batch_points if parent_plan_point # rubocop:disable Style/SafeNavigation
end

#serializer_classObject

Serializer class of current plan



95
96
97
# File 'lib/serega/plan.rb', line 95

def serializer_class
  self.class.serializer_class
end