Class: Recliner::ViewGenerator

Inherits:
Object
  • Object
show all
Extended by:
ActiveSupport::Memoizable
Defined in:
lib/recliner/views/generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ViewGenerator

Returns a new instance of ViewGenerator.



7
8
9
# File 'lib/recliner/views/generator.rb', line 7

def initialize(options={})
  @options = { :conditions! => {}, :order => :_id }.merge(options)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/recliner/views/generator.rb', line 5

def options
  @options
end

Instance Method Details

#generateObject



11
12
13
14
15
16
17
18
19
# File 'lib/recliner/views/generator.rb', line 11

def generate
  map = ""
  
  map << "if (#{conditions}) {\n" unless conditions.blank?
  map << "  emit(#{key}, #{value});\n"
  map << "}\n" unless conditions.blank?
  
  [ViewFunction::Map.new(map), nil]
end