class Rawscsi::IndexHelpers::SdfAdd
Attributes
attributes[R]
doc[R]
Public Class Methods
new(doc, attributes=nil)
click to toggle source
# File lib/rawscsi/index_helpers/sdf_add.rb, line 6 def initialize(doc, attributes=nil) @doc = doc @attributes = attributes || doc.keys end
Public Instance Methods
build()
click to toggle source
# File lib/rawscsi/index_helpers/sdf_add.rb, line 11 def build { :id => doc_id, :type => "add", :fields => fields } end
Private Instance Methods
doc_id()
click to toggle source
# File lib/rawscsi/index_helpers/sdf_add.rb, line 20 def doc_id if doc.is_a?(Hash) doc[:id] else "#{doc.class}_#{doc.id}" end end
fields()
click to toggle source
# File lib/rawscsi/index_helpers/sdf_add.rb, line 28 def fields output = {} attributes.each do |attr| next if attr == :id output[attr] = get_attr(doc, attr) end output end
get_attr(doc, attr)
click to toggle source
# File lib/rawscsi/index_helpers/sdf_add.rb, line 37 def get_attr(doc, attr) if doc.is_a?(Hash) doc[attr] else doc.send(attr) end end