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

- (BaseViewSpec) initialize(klass, view_name, options, view_parameters)



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

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]
  @language = options[:language] || Config.default_language

  assert_valid_view_parameters normalized_view_parameters
  @klass = klass
  @design_document = translate_to_design_doc_name(klass.to_s, view_name, @list_name)
  @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

- (Object) design_document (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

- (Object) language (readonly)

Returns the value of attribute language



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

def language
  @language
end

- (Object) lib (readonly)

Returns the value of attribute lib



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

def lib
  @lib
end

- (Object) list_function (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

- (Object) list_name (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

- (Object) reduce_function (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

- (Object) view_name (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

- (Object) view_parameters

Returns the value of attribute view_parameters



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

def view_parameters
  @view_parameters
end

Instance Method Details

- (Object) process_results(results)



29
30
31
32
33
34
35
# File 'lib/couch_potato/view/base_view_spec.rb', line 29

def process_results(results)
  if (filter = options[:results_filter])
    filter.call results
  else
    results
  end
end