Class: CouchPotato::View::ModelViewSpec::ErlangGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/couch_potato/view/model_view_spec.rb

Instance Method Summary collapse

Constructor Details

#initialize(options, klass) ⇒ ErlangGenerator

Returns a new instance of ErlangGenerator.



15
16
17
18
# File 'lib/couch_potato/view/model_view_spec.rb', line 15

def initialize(options, klass)
  @options = options
  @klass = klass
end

Instance Method Details

#map_functionObject

Raises:

  • (NotImplementedError)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/couch_potato/view/model_view_spec.rb', line 20

def map_function
  raise NotImplementedError.new("conditions in Erlang not implemented") if @options[:conditions]
    raise NotImplementedError.new("emit_value in Erlang not implemented") if @options[:emit_value]
    <<-ERL
    fun({Doc}) ->
       case proplists:get_value(<<"#{JSON.create_id}">>, Doc) of
       <<"#{@klass.name}">> ->
         #{formatted_key},
         Emit(#{composite_key_brackets emit_key}, 1);
       _ ->
         ok
       end
     end.
    ERL
end