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.



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

def initialize(factory)
  @params = nil

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

Instance Method Details

#to_procObject



138
139
140
141
142
143
144
145
146
# File 'lib/text_extractor/record.rb', line 138

def to_proc
  if @params
    explicit
  elsif @klass.respond_to?(:call)
    @klass
  elsif @klass
    implicit
  end
end