Class: MundaneSearch::Result

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Buildable
Defined in:
lib/mundane-search/result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection, params) ⇒ Result

Returns a new instance of Result.



11
12
13
# File 'lib/mundane-search/result.rb', line 11

def initialize(collection, params)
  @stack = self.class.builder.result_for(collection,params)
end

Instance Attribute Details

#stackObject (readonly)

Returns the value of attribute stack.



10
11
12
# File 'lib/mundane-search/result.rb', line 10

def stack
  @stack
end

Class Method Details

.optionsObject



6
7
8
# File 'lib/mundane-search/result.rb', line 6

def self.options
  @options ||= {}
end

.result_model_classObject



19
20
21
# File 'lib/mundane-search/result.rb', line 19

def self.result_model_class
  @result_model_class ||= ResultModel.model_class_for(self)
end

Instance Method Details

#each(*args, &block) ⇒ Object



27
28
29
30
# File 'lib/mundane-search/result.rb', line 27

def each(*args, &block)
  return enum_for(__callee__) unless block_given?
  to_a.each(*args, &block)
end

#to_aObject



23
24
25
# File 'lib/mundane-search/result.rb', line 23

def to_a
  stack.collection
end

#to_modelObject



15
16
17
# File 'lib/mundane-search/result.rb', line 15

def to_model
  @result_model ||= self.class.result_model_class.new(self)
end