flare 1.1.0 → 1.2.0

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/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
data/flare.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{flare}
8
- s.version = "1.1.0"
8
+ s.version = "1.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Dwan"]
12
- s.date = %q{2010-01-18}
12
+ s.date = %q{2010-01-26}
13
13
  s.description = %q{This needs to get updated}
14
14
  s.email = %q{mpdwan@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -73,7 +73,11 @@ module Flare
73
73
 
74
74
  module InstanceMethods
75
75
  def to_solr_doc
76
- doc = { :id => solr_document_id, :type => self.class.name }
76
+ doc = {
77
+ :fields => { :id => solr_document_id, :type => self.class.name },
78
+ :attributes => {}
79
+ }
80
+
77
81
  solr_index[:fields].each do |field|
78
82
  value = send(field[:source])
79
83
  # Need to convert dates to utc xmlschema.
@@ -81,8 +85,13 @@ module Flare
81
85
  if value.respond_to?(:utc)
82
86
  value = value.utc.xmlschema
83
87
  end
84
- doc[field[:name]] = value
88
+ doc[:fields][field[:name]] = value
89
+ end
90
+
91
+ solr_index[:attributes].each do |key, value|
92
+ doc[:attributes][key] = value.kind_of?(Symbol) ? send(value) : value
85
93
  end
94
+
86
95
  doc
87
96
  end
88
97
 
@@ -4,11 +4,12 @@ module Flare
4
4
 
5
5
  def initialize(&block)
6
6
  @fields = []
7
+ @attributes = {}
7
8
  self.instance_eval(&block) if block_given?
8
9
  end
9
10
 
10
11
  def index
11
- { :fields => @fields }
12
+ { :fields => @fields, :attributes => @attributes }
12
13
  end
13
14
 
14
15
  protected
@@ -20,5 +21,9 @@ module Flare
20
21
  :boost => options[:boost] || nil
21
22
  }
22
23
  end
24
+
25
+ def attribute(name, value)
26
+ @attributes[name] = value
27
+ end
23
28
  end
24
29
  end
data/lib/flare/session.rb CHANGED
@@ -25,7 +25,10 @@ module Flare
25
25
 
26
26
  def index(*objects)
27
27
  objects = ensure_searchable(objects)
28
- connection.add(objects.collect(&:to_solr_doc))
28
+ objects.collect(&:to_solr_doc).each do |doc|
29
+ connection.update(RSolr::Message::Builder.new.add(doc[:fields], doc[:attributes]))
30
+ # connection.add(doc[:fields], doc[:attributes])
31
+ end
29
32
  end
30
33
 
31
34
  def index!(*objects)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flare
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Dwan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-18 00:00:00 -06:00
12
+ date: 2010-01-26 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency