Class: Resto::Translator::Factory

Inherits:
Object
  • Object
show all
Defined in:
lib/resto/translator/request_factory.rb,
lib/resto/translator/request_factory.rb

Direct Known Subclasses

RequestFactory, ResponseFactory

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keys) ⇒ Factory

Returns a new instance of Factory.



26
27
28
# File 'lib/resto/translator/request_factory.rb', line 26

def initialize(keys)
  @keys = keys
end

Class Method Details

.create(translator) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/resto/translator/request_factory.rb', line 8

def create(translator)
  if translator.is_a?(Symbol) and :default == translator
    new([])
  elsif translator.is_a?(Array)
    new(translator)
  elsif translator.is_a?(Proc)
    translator
  elsif translator.is_a?(Class)
    translator.new
  else
    raise(ArgumentError,
          "Invalid argument. Valid symbol is :default. Array, Class or a
          Proc is also a valid translator.")
  end
end