Class: Pocolog::Upgrade::Ops::Custom
- Defined in:
- lib/pocolog/upgrade/ops/custom.rb
Overview
Definition of a custom conversion of a given type to another
Instance Attribute Summary collapse
-
#converter ⇒ #call
readonly
The object that will perform the conversion.
-
#from_type ⇒ Typelib::Type
The expected type signature of the value that will be converted.
-
#name ⇒ String
readonly
The descriptive name of the converter.
-
#time_to ⇒ Time
readonly
The validity limit for this converter Samples created after this time won't be valid.
-
#to_type ⇒ Object
writeonly
Sets the attribute to_type.
Attributes inherited from Base
Instance Method Summary collapse
- #call(target, sample) ⇒ Object
-
#initialize(time_to, from_type, to_type, converter, name: nil) ⇒ Custom
constructor
Create a type converter for a given type, with an optional time limit.
Methods inherited from Base
Constructor Details
#initialize(time_to, from_type, to_type, converter, name: nil) ⇒ Custom
Create a type converter for a given type, with an optional time limit
34 35 36 37 38 39 40 |
# File 'lib/pocolog/upgrade/ops/custom.rb', line 34 def initialize(time_to, from_type, to_type, converter, name: nil) @name = name @time_to = time_to @from_type = from_type super(to_type) @converter = converter end |
Instance Attribute Details
#converter ⇒ #call (readonly)
Returns the object that will perform the conversion
21 22 23 |
# File 'lib/pocolog/upgrade/ops/custom.rb', line 21 def converter @converter end |
#from_type ⇒ Typelib::Type
Returns the expected type signature of the value that will be converted
16 17 18 |
# File 'lib/pocolog/upgrade/ops/custom.rb', line 16 def from_type @from_type end |
#name ⇒ String (readonly)
Returns the descriptive name of the converter
7 8 9 |
# File 'lib/pocolog/upgrade/ops/custom.rb', line 7 def name @name end |
#time_to ⇒ Time (readonly)
Returns the validity limit for this converter Samples created after this time won't be valid. Leave nil if this converter is purely based on type signatures.
12 13 14 |
# File 'lib/pocolog/upgrade/ops/custom.rb', line 12 def time_to @time_to end |
#to_type=(value) ⇒ Object (writeonly)
Sets the attribute to_type
18 19 20 |
# File 'lib/pocolog/upgrade/ops/custom.rb', line 18 def to_type=(value) @to_type = value end |
Instance Method Details
#call(target, sample) ⇒ Object
42 43 44 |
# File 'lib/pocolog/upgrade/ops/custom.rb', line 42 def call(target, sample) converter.call(target, sample) end |