Class: Dynflow::Serializers::Abstract Abstract
- Inherits:
 - 
      Object
      
        
- Object
 - Dynflow::Serializers::Abstract
 
 
- Defined in:
 - lib/dynflow/serializers/abstract.rb
 
Overview
Used to serialize and deserialize arguments for storage in a database. Used by DelayedPlan to store arguments which should be passed into the Action‘s #plan method when the plan is executed.
Direct Known Subclasses
Instance Attribute Summary collapse
- 
  
    
      #args  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute args.
 - 
  
    
      #serialized_args  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute serialized_args.
 
Instance Method Summary collapse
- 
  
    
      #args!  ⇒ Array 
    
    
  
  
  
  
  
  
  
  
  
    
Retrieves the arguments.
 - 
  
    
      #deserialize(arg)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Converts a serialized argument into its deserialized form.
 - 
  
    
      #initialize(args, serialized_args = nil)  ⇒ Abstract 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Abstract.
 - 
  
    
      #perform_deserialization!  ⇒ Array 
    
    
  
  
  
  
  
  
  
  
  
    
Converts arguments into their deserialized form, iterates over serialized arguments, applying #deserialize to each of them.
 - 
  
    
      #perform_serialization!  ⇒ Array 
    
    
  
  
  
  
  
  
  
  
  
    
Converts arguments into their serialized form, iterates over deserialized arguments, applying #serialize to each of them.
 - 
  
    
      #serialize(arg)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Converts an argument into it serialized form.
 - 
  
    
      #serialized_args!  ⇒ Array 
    
    
  
  
  
  
  
  
  
  
  
    
Retrieves the arguments in the serialized form.
 
Constructor Details
#initialize(args, serialized_args = nil) ⇒ Abstract
Returns a new instance of Abstract.
      14 15 16 17  | 
    
      # File 'lib/dynflow/serializers/abstract.rb', line 14 def initialize(args, serialized_args = nil) @args = args @serialized_args = serialized_args end  | 
  
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
      10 11 12  | 
    
      # File 'lib/dynflow/serializers/abstract.rb', line 10 def args @args end  | 
  
#serialized_args ⇒ Object (readonly)
Returns the value of attribute serialized_args.
      10 11 12  | 
    
      # File 'lib/dynflow/serializers/abstract.rb', line 10 def serialized_args @serialized_args end  | 
  
Instance Method Details
#args! ⇒ Array
Retrieves the arguments
      23 24 25 26  | 
    
      # File 'lib/dynflow/serializers/abstract.rb', line 23 def args! raise "@args not set" if @args.nil? return @args end  | 
  
#deserialize(arg) ⇒ Object
Converts a serialized argument into its deserialized form
      65 66 67  | 
    
      # File 'lib/dynflow/serializers/abstract.rb', line 65 def deserialize(arg) raise NotImplementedError end  | 
  
#perform_deserialization! ⇒ Array
Converts arguments into their deserialized form, iterates over serialized arguments, applying #deserialize to each of them
      51 52 53  | 
    
      # File 'lib/dynflow/serializers/abstract.rb', line 51 def perform_deserialization! @args = serialized_args!.map { |arg| deserialize arg } end  | 
  
#perform_serialization! ⇒ Array
Converts arguments into their serialized form, iterates over deserialized arguments, applying #serialize to each of them
      42 43 44  | 
    
      # File 'lib/dynflow/serializers/abstract.rb', line 42 def perform_serialization! @serialized_args = args!.map { |arg| serialize arg } end  | 
  
#serialize(arg) ⇒ Object
Converts an argument into it serialized form
      58 59 60  | 
    
      # File 'lib/dynflow/serializers/abstract.rb', line 58 def serialize(arg) raise NotImplementedError end  | 
  
#serialized_args! ⇒ Array
Retrieves the arguments in the serialized form
      32 33 34 35  | 
    
      # File 'lib/dynflow/serializers/abstract.rb', line 32 def serialized_args! raise "@serialized_args not set" if @serialized_args.nil? return @serialized_args end  |