Module: N4j::Node::Index

Extended by:
ActiveSupport::Concern
Defined in:
lib/n4j/index.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#add_to_index(key) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/n4j/index.rb', line 35

def add_to_index(key)
  index = {
    "value" => send(key),
    "uri"   => url,
    "key"   => key
  }

  N4j.batch([{:to => "#{index_path}",:method => 'POST',:body => index }])
end

#index_hashesObject

(opts ={}) <- the normal argument pattern doesn’t really work here.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/n4j/index.rb', line 49

def index_hashes # (opts ={}) <- the normal argument pattern doesn't really work here.
  if (indexes = self.class.indexes)
    indexes.collect do |index|
      if (value = send(index))
        index = {
          "value" => send(index),
          "uri"   => url,
          "key"   => index
        }
        {:to => "#{index_path}",:method => 'POST',:body => index }
      end
    end.compact
  end
end

#index_pathObject



45
46
47
# File 'lib/n4j/index.rb', line 45

def index_path
  "/index/node/#{self.class.index_name}"
end