Class: Mohair::Inserter
- Inherits:
-
Object
- Object
- Mohair::Inserter
- Defined in:
- lib/mohair/inserter.rb
Instance Method Summary collapse
- #exec! ⇒ Object
-
#initialize(bucket_name) ⇒ Inserter
constructor
A new instance of Inserter.
- #insert_all(objs) ⇒ Object
- #pr ⇒ Object
Constructor Details
#initialize(bucket_name) ⇒ Inserter
Returns a new instance of Inserter.
6 7 8 |
# File 'lib/mohair/inserter.rb', line 6 def initialize bucket_name @bucket_name = bucket_name end |
Instance Method Details
#exec! ⇒ Object
34 35 |
# File 'lib/mohair/inserter.rb', line 34 def exec! end |
#insert_all(objs) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mohair/inserter.rb', line 9 def insert_all objs @client = Riak::Client.new(:protocol => "http") bucket = @client.bucket(@bucket_name) if bucket.props["allow_mult"] then $stderr.puts "allow_mult should be false (how to handle siblilngs?)" return end objs.each do |obj| r_o = Riak::RObject.new(bucket, obj["key"]) data = r_o.data = obj["data"] obj["data"].each do |k,v| begin if integer? v then r_o.indexes[k + "_int"] << v end rescue r_o.indexes[k + "_bin"] << v end end r_o.content_type = 'application/json' r_o.store print obj["key"] , "\t => ", data, "\n" end end |
#pr ⇒ Object
36 37 |
# File 'lib/mohair/inserter.rb', line 36 def pr end |