Class: Uniword::FindReplace::Scope::TextAccessor
- Inherits:
-
Object
- Object
- Uniword::FindReplace::Scope::TextAccessor
- Defined in:
- lib/uniword/find_replace/scope.rb
Overview
Small value object with a value reader and value=
writer, backed by lambdas. Avoids instance_variable_set /
send; lets callers wire read/write however they like.
Instance Method Summary collapse
-
#initialize(reader, writer) ⇒ TextAccessor
constructor
A new instance of TextAccessor.
- #value ⇒ Object
- #value=(new_value) ⇒ Object
Constructor Details
#initialize(reader, writer) ⇒ TextAccessor
Returns a new instance of TextAccessor.
83 84 85 86 |
# File 'lib/uniword/find_replace/scope.rb', line 83 def initialize(reader, writer) @reader = reader @writer = writer end |
Instance Method Details
#value ⇒ Object
88 89 90 |
# File 'lib/uniword/find_replace/scope.rb', line 88 def value @reader.call end |
#value=(new_value) ⇒ Object
92 93 94 |
# File 'lib/uniword/find_replace/scope.rb', line 92 def value=(new_value) @writer.call(new_value) end |