Class: CouchPotato::View::BaseViewSpec

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

Direct Known Subclasses

CustomViewSpec, ModelViewSpec, RawViewSpec

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, view_name, options, view_parameters) ⇒ BaseViewSpec

Returns a new instance of BaseViewSpec.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/couch_potato/view/base_view_spec.rb', line 7

def initialize(klass, view_name, options, view_parameters)
  normalized_view_parameters = normalize_view_parameters view_parameters
  
  @list_name = normalized_view_parameters.delete(:list) || options[:list]
  
  assert_valid_view_parameters normalized_view_parameters
  @klass = klass
  # If there is a specified design name generator, we use that one
  @design_document = CouchPotato.design_name_fun.call klass
  @view_name = view_name
  @options = options
  
  @list_function = klass.lists(@list_name) if @list_name
  @view_parameters = {}
  [:group, :include_docs, :descending, :group_level, :limit].each do |key|
    @view_parameters[key] = options[key] if options.include?(key)
  end
  @view_parameters.merge!(normalized_view_parameters)
end

Instance Attribute Details

#design_documentObject (readonly)

Returns the value of attribute design_document.



4
5
6
# File 'lib/couch_potato/view/base_view_spec.rb', line 4

def design_document
  @design_document
end

#list_functionObject (readonly)

Returns the value of attribute list_function.



4
5
6
# File 'lib/couch_potato/view/base_view_spec.rb', line 4

def list_function
  @list_function
end

#list_nameObject (readonly)

Returns the value of attribute list_name.



4
5
6
# File 'lib/couch_potato/view/base_view_spec.rb', line 4

def list_name
  @list_name
end

#reduce_functionObject (readonly)

Returns the value of attribute reduce_function.



4
5
6
# File 'lib/couch_potato/view/base_view_spec.rb', line 4

def reduce_function
  @reduce_function
end

#view_nameObject (readonly)

Returns the value of attribute view_name.



4
5
6
# File 'lib/couch_potato/view/base_view_spec.rb', line 4

def view_name
  @view_name
end

#view_parametersObject (readonly)

Returns the value of attribute view_parameters.



4
5
6
# File 'lib/couch_potato/view/base_view_spec.rb', line 4

def view_parameters
  @view_parameters
end

Instance Method Details

#process_results(results) ⇒ Object



27
28
29
# File 'lib/couch_potato/view/base_view_spec.rb', line 27

def process_results(results)
  results
end