Class: Pocolog::Upgrade::Ops::CompoundCast

Inherits:
Base
  • Object
show all
Defined in:
lib/pocolog/upgrade/ops/compound_cast.rb

Overview

Casts a field in a compound

Instance Attribute Summary collapse

Attributes inherited from Base

#to_type

Instance Method Summary collapse

Methods inherited from Base

#convert, #identity?

Constructor Details

#initialize(field_convertions, to_type) ⇒ CompoundCast

Returns a new instance of CompoundCast



8
9
10
11
# File 'lib/pocolog/upgrade/ops/compound_cast.rb', line 8

def initialize(field_convertions, to_type)
    @field_convertions = field_convertions
    super(to_type)
end

Instance Attribute Details

#field_convertionsObject (readonly)

Returns the value of attribute field_convertions



6
7
8
# File 'lib/pocolog/upgrade/ops/compound_cast.rb', line 6

def field_convertions
  @field_convertions
end

Instance Method Details

#call(target, value) ⇒ Object



13
14
15
16
17
# File 'lib/pocolog/upgrade/ops/compound_cast.rb', line 13

def call(target, value)
    field_convertions.each do |field_name, field_ops|
        field_ops.call(target.raw_get(field_name), value.raw_get(field_name))
    end
end