sunspot_association 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sunspot_association (0.0.2)
4
+ sunspot_association (0.1.1)
5
5
  activerecord (~> 3.0)
6
6
  sunspot_rails
7
7
 
@@ -67,6 +67,8 @@ module SunspotAssociation
67
67
 
68
68
  # Main callback method, checks if it should reindex an association
69
69
  def reindex_sunspot_associations!(event)
70
+ return false unless self.class.sunspot_associate?
71
+
70
72
  self.class.sunspot_association_configuration.each do |object, config|
71
73
  case event
72
74
  when :create
@@ -82,6 +84,8 @@ module SunspotAssociation
82
84
  # Checks if an association should be reindexed
83
85
  # => reindex_sunspot_association?(:orders) => true
84
86
  def reindex_sunspot_association?(object)
87
+ return false unless self.class.sunspot_associate?
88
+
85
89
  if (config = (self.class.sunspot_association_configuration || {})[object]).present?
86
90
  if config[:fields].present?
87
91
  return ! (changed & (config[:fields] || []).map(&:to_s)).empty?
@@ -65,9 +65,11 @@ module SunspotAssociation
65
65
  def setup_association_reindex(association_name, fields, options={})
66
66
  searchable_class = @setup.clazz
67
67
  association = searchable_class.reflect_on_association(association_name)
68
- association_class = association.klass
68
+ association_class = association.try(:klass)
69
69
  inverse_name = options[:inverse_name] || searchable_class.name.pluralize.downcase.to_sym
70
70
 
71
+ return false if association_class.nil?
72
+
71
73
  association_class.sunspot_associate inverse_name, :fields => fields
72
74
  end
73
75
 
@@ -1,3 +1,3 @@
1
1
  module SunspotAssociation
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunspot_association
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-10 00:00:00.000000000 Z
12
+ date: 2013-04-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler