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



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

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.



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

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



43
44
45
# File 'lib/n4j/index.rb', line 43

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