Module: AssayDepot::Model

Defined in:
lib/assaydepot/model.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/assaydepot/model.rb', line 135

def self.included(base)
  base.extend ClassMethods
  base.extend Forwardable
  base.def_delegators  :private_results,
                  :each,
                  :[],
                  :count,
                  :collect,
                  :map,
                  :tap,
                  :<=>,
                  :compact,
                  :each_index,
                  :each_with_index,
                  :empty?,
                  :flatten,
                  :include?,
                  :index,
                  :length,
                  :first,
                  :last,
                  :keep_if,
                  :reject,
                  :reverse

  attr_accessor :internal_options
end

Instance Method Details

#initialize(options = {}) ⇒ Object



163
164
165
# File 'lib/assaydepot/model.rb', line 163

def initialize(options={})
  @internal_options = options[:search_options] || { }
end

#initialize_copy(source) ⇒ Object



167
168
169
170
171
# File 'lib/assaydepot/model.rb', line 167

def initialize_copy(source)
  super
  @search_query = @search_query.dup
  @search_facets = @search_facets.dup
end

#options(options = {}) ⇒ Object



181
182
183
184
185
# File 'lib/assaydepot/model.rb', line 181

def options(options={})
  result = self.clone
  result.internal_options = self.internal_options ? self.internal_options.merge(options) : options
  result
end

#private_resultsObject



187
188
189
# File 'lib/assaydepot/model.rb', line 187

def private_results
  internal_results[self.class.ref_name]
end

#query_timeObject



173
174
175
# File 'lib/assaydepot/model.rb', line 173

def query_time
  internal_results["query_time"]
end

#totalObject



177
178
179
# File 'lib/assaydepot/model.rb', line 177

def total
  internal_results["total"]
end