class SimpleRewriter::Reader

Constants

INDEX_OF_ATTRIBUTE_NAME

Attributes

attribute_with_options[R]
attributes[R]
record[R]

Public Class Methods

call(record, attributes) { |data| ... } click to toggle source
# File lib/simple_rewriter/reader.rb, line 4
def self.call(record, attributes)
  new(record, attributes).call { |data| yield(data) }
end
new(record, attributes) click to toggle source
# File lib/simple_rewriter/reader.rb, line 8
def initialize(record, attributes)
  @record = record
  @attributes = attributes
end

Public Instance Methods

call() { |attribute, attr_value, options| ... } click to toggle source
# File lib/simple_rewriter/reader.rb, line 13
def call
  attributes.each do |attribute_with_options|
    @attribute_with_options = attribute_with_options

    yield [attribute, attr_value, options]
  end
end

Private Instance Methods

attr_value() click to toggle source
# File lib/simple_rewriter/reader.rb, line 25
def attr_value
  reader.call(attribute)
end
attribute() click to toggle source
# File lib/simple_rewriter/reader.rb, line 33
def attribute
  attributes_resolver.call(attribute: attribute_with_options).attribute
end
attributes_resolver() click to toggle source
# File lib/simple_rewriter/reader.rb, line 41
def attributes_resolver
  SimpleRewriter::AttributeResolver
end
options() click to toggle source
# File lib/simple_rewriter/reader.rb, line 37
def options
  attributes_resolver.call(attribute: attribute_with_options).options
end
reader() click to toggle source
# File lib/simple_rewriter/reader.rb, line 29
def reader
  @_reader ||= reader_class.new(record: record)
end
reader_class() click to toggle source
# File lib/simple_rewriter/reader.rb, line 45
def reader_class
  SimpleRewriter::ClassResolver.call(record, "SimpleRewriter::Readers::%{klass}Reader")
end