Class: Uniword::FindReplace::Scope::TextAccessor

Inherits:
Object
  • Object
show all
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

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

#valueObject



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