Class: Ansr::Base
Class Method Summary
collapse
Instance Method Summary
collapse
config
all_filter_fields, all_sort_fields, ansr_query, as, as!, as_unscoping, as_value, as_value=, build_arel, build_facets, build_where, collapse_filters, collapse_wheres, facet, facet!, facet_unscoping, facet_values, facet_values=, field_name, filter, filter!, filter_name, filter_unscoping, filter_values, filter_values=, find, find_by_nosql, highlight, highlight!, highlight_unscoping, highlight_value, highlight_value=, spellcheck, spellcheck!, spellcheck_unscoping, spellcheck_value, spellcheck_value=
arel, arel_table
Constructor Details
#initialize(doc = {}, options = {}) ⇒ Base
Returns a new instance of Base.
22
23
24
25
|
# File 'lib/ansr/base.rb', line 22
def initialize doc={}, options={}
super(filter_source_hash(doc), options)
@source_doc = doc
end
|
Class Method Details
.method ⇒ Object
14
15
16
|
# File 'lib/ansr/base.rb', line 14
def self.method
@method ||= :get
end
|
.method=(method) ⇒ Object
18
19
20
|
# File 'lib/ansr/base.rb', line 18
def self.method=(method)
@method = method
end
|
Instance Method Details
#[](key) ⇒ Object
60
61
62
|
# File 'lib/ansr/base.rb', line 60
def [](key)
@source_doc[key]
end
|
#columns(name = self.name) ⇒ Object
56
57
58
|
# File 'lib/ansr/base.rb', line 56
def columns(name=self.name)
super(name)
end
|
#core_initialize(attributes = nil, options = {}) {|_self| ... } ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/ansr/base.rb', line 27
def core_initialize(attributes = nil, options = {})
defaults = self.class.column_defaults.dup
defaults.each { |k, v| defaults[k] = v.dup if v.duplicable? }
@attributes = self.class.initialize_attributes(defaults)
@column_types_override = nil
@column_types = self.class.column_types
init_internals
init_changed_attributes
ensure_proper_type
populate_with_current_scope_attributes
init_attributes(attributes, options) if attributes
yield self if block_given?
run_callbacks :initialize unless _initialize_callbacks.empty?
end
|
#filter_source_hash(doc) ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/ansr/base.rb', line 48
def filter_source_hash(doc)
fields = self.class.model().table().fields()
filtered = doc.select do |k,v|
fields.include? k.to_sym
end
filtered.with_indifferent_access
end
|