asari 0.7.2 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +20 -0
- data/lib/asari.rb +1 -1
- data/lib/asari/active_record.rb +5 -2
- data/lib/asari/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -119,6 +119,26 @@ In the above example we decide that, instead of raising exceptions every time,
|
|
119
119
|
we're going to log exception data to Airbrake so that we can review it later and
|
120
120
|
then return true so that the AR lifecycle continues normally.
|
121
121
|
|
122
|
+
#### AWS Region
|
123
|
+
|
124
|
+
By default, Asari assumes that you're operating in us-east-1, which is probably
|
125
|
+
not a helpful assumption for some of you. To fix this, either set the
|
126
|
+
`aws_region` property on your raw Asari object:
|
127
|
+
|
128
|
+
a = Asari.new("my-search-domain")
|
129
|
+
a.aws_region = "us-west-1"
|
130
|
+
|
131
|
+
...Or provide the `:aws_region` option when you call `asari_index` on an
|
132
|
+
ActiveRecord model:
|
133
|
+
|
134
|
+
class User < ActiveRecord::Base
|
135
|
+
include Asari::ActiveRecord
|
136
|
+
|
137
|
+
asari_index("my-search-domain",[field1,field2], :aws_regon => "us-west-1")
|
138
|
+
|
139
|
+
...
|
140
|
+
end
|
141
|
+
|
122
142
|
## Get it
|
123
143
|
|
124
144
|
It's a gem named asari. Install it and make it available however you prefer.
|
data/lib/asari.rb
CHANGED
data/lib/asari/active_record.rb
CHANGED
@@ -41,13 +41,15 @@ class Asari
|
|
41
41
|
# fields - an array of Symbols representing the list of fields that
|
42
42
|
# should be included in this index.
|
43
43
|
# options - a hash of extra options to consider when indexing this
|
44
|
-
# model.
|
44
|
+
# model. Options:
|
45
45
|
# when - a string or symbol representing a method name, or a Proc to
|
46
46
|
# evaluate to determine if this model object should be indexed. On
|
47
47
|
# creation, if the method or Proc specified returns false, the
|
48
48
|
# model will not be indexed. On update, if the method or Proc
|
49
49
|
# specified returns false, the model will be removed from the
|
50
50
|
# index (if it exists there).
|
51
|
+
# aws_region - if this model is indexed on an AWS region other than
|
52
|
+
# us-east-1, specify it with this option.
|
51
53
|
#
|
52
54
|
# Examples:
|
53
55
|
# class User < ActiveRecord::Base
|
@@ -60,7 +62,8 @@ class Asari
|
|
60
62
|
# asari_index("my-companies-users-asglkj4rsagkjlh34", [:name, :email], :when => Proc.new({ |user| user.published && !user.admin? }))
|
61
63
|
#
|
62
64
|
def asari_index(search_domain, fields, options = {})
|
63
|
-
|
65
|
+
aws_region = options.delete(:aws_region)
|
66
|
+
self.class_variable_set(:@@asari_instance, Asari.new(search_domain,aws_region))
|
64
67
|
self.class_variable_set(:@@asari_fields, fields)
|
65
68
|
self.class_variable_set(:@@asari_when, options.delete(:when))
|
66
69
|
end
|
data/lib/asari/version.rb
CHANGED