Class: TextExtractor::Record::FactoryAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/text_extractor/record.rb

Overview

converts the value of the factory option to a constructor proc

Instance Method Summary collapse

Constructor Details

#initialize(factory) ⇒ FactoryAnalyzer

Returns a new instance of FactoryAnalyzer.



115
116
117
118
119
120
121
122
123
124
# File 'lib/text_extractor/record.rb', line 115

def initialize(factory)
  @params = nil

  case factory
  when Hash
    @klass, @params = factory.first
  else
    @klass = factory
  end
end

Instance Method Details

#to_procObject



126
127
128
129
130
131
132
133
134
# File 'lib/text_extractor/record.rb', line 126

def to_proc
  if @params
    explicit
  elsif @klass.is_a?(Proc)
    @klass
  elsif @klass
    implicit
  end
end