Skip to content

Commit

Permalink
don't delete block option when indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanb committed Sep 2, 2011
1 parent 237d9af commit f51ea0f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/xapit/client/index_builder.rb
Expand Up @@ -39,6 +39,7 @@ def update_document(member)
def document_data(member)
data = {:class => member.class.name, :id => member.id, :attributes => {}}
attributes.each do |name, options|
options = options.dup # so we can remove block without changing original hash
value = member.send(name)
value = options.delete(:_block).call(value) if options[:_block]
data[:attributes][name] = options.merge(:value => value)
Expand Down
1 change: 1 addition & 0 deletions spec/xapit/client/index_builder_spec.rb
Expand Up @@ -61,6 +61,7 @@
member = XapitMember.new(:greeting => "hello")
data = builder.document_data(member)
data[:attributes].should eq(:greeting => {:value => "olleh", :text => {}})
builder.attributes[:greeting][:_block].should_not be_nil
end

it "indexes an object by adding it to the current database" do
Expand Down

0 comments on commit f51ea0f

Please sign in to comment.