asari 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -22,7 +22,7 @@ class Asari
22
22
  attr_writer :search_domain
23
23
  attr_writer :aws_region
24
24
 
25
- def initialize(search_domain=nil)
25
+ def initialize(search_domain=nil, aws_region=nil)
26
26
  @search_domain = search_domain
27
27
  end
28
28
 
@@ -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. Right now, only one option is available:
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
- self.class_variable_set(:@@asari_instance, Asari.new(search_domain))
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
@@ -1,3 +1,3 @@
1
1
  class Asari
2
- VERSION = "0.7.2"
2
+ VERSION = "0.7.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asari
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: