Class: Pocolog::Upgrade::Ops::Base
- Inherits:
-
Object
- Object
- Pocolog::Upgrade::Ops::Base
- Defined in:
- lib/pocolog/upgrade/ops/base.rb
Overview
Direct Known Subclasses
ArrayCast, CompoundCast, ContainerCast, Custom, EnumCast, Identity, NumericCast, Sequence
Instance Attribute Summary collapse
-
#to_type ⇒ Object
readonly
Returns the value of attribute to_type.
Instance Method Summary collapse
- #call(target, value) ⇒ Object
- #convert(value) ⇒ Object
- #identity? ⇒ Boolean
-
#initialize(to_type) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(to_type) ⇒ Base
Returns a new instance of Base.
11 12 13 |
# File 'lib/pocolog/upgrade/ops/base.rb', line 11 def initialize(to_type) @to_type = to_type end |
Instance Attribute Details
#to_type ⇒ Object (readonly)
Returns the value of attribute to_type.
9 10 11 |
# File 'lib/pocolog/upgrade/ops/base.rb', line 9 def to_type @to_type end |
Instance Method Details
#call(target, value) ⇒ Object
15 16 17 |
# File 'lib/pocolog/upgrade/ops/base.rb', line 15 def call(target, value) Typelib.copy(target, convert(value)) end |
#convert(value) ⇒ Object
19 20 21 22 23 |
# File 'lib/pocolog/upgrade/ops/base.rb', line 19 def convert(value) target = to_type.new call(target, value) target end |
#identity? ⇒ Boolean
25 26 27 |
# File 'lib/pocolog/upgrade/ops/base.rb', line 25 def identity? false end |