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

#parent_plan_pointSeregaPlanPoint? (readonly)

Parent plan point

Returns:



77
78
79
# File 'lib/serega/plan.rb', line 77

def parent_plan_point
  @parent_plan_point
end

#pointsArray<SeregaPlanPoint> (readonly)

Serialization points

Returns:



81
82
83
# File 'lib/serega/plan.rb', line 81

def points
  @points
end

#points_hashHash (readonly)

Named serialization points

Returns:

  • (Hash)

    Named points



85
86
87
# File 'lib/serega/plan.rb', line 85

def points_hash
  @points_hash
end

Instance Method Details

#data_classClass

Returns the Data class whose members match this plan's serialized fields. Delegates to the class-level cache so identical field sets share one Data class.

Returns:

  • (Class)

    Subclass of Data



119
120
121
# File 'lib/serega/plan.rb', line 119

def data_class
  @data_class ||= self.class.data_class_for(point_names)
end

#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

Parameters:

  • parent_plan_point (SeregaPlanPoint, nil)

    Parent plan_point

  • modifiers (Hash)

    Serialization parameters

Options Hash (modifiers):

  • :only (Hash)

    The only attributes to serialize

  • :except (Hash)

    Attributes to hide

  • :with (Hash)

    Hidden attributes to serialize additionally

Returns:



101
102
103
104
105
# File 'lib/serega/plan.rb', line 101

def initialize(parent_plan_point, modifiers)
  @parent_plan_point = parent_plan_point
  @points = attributes_points(modifiers)
  @points_hash = points.to_h { |point| [point.name, point] }
end

#serializer_classObject

Serializer class of current plan



110
111
112
# File 'lib/serega/plan.rb', line 110

def serializer_class
  self.class.serializer_class
end