Sha256: 43336bd3e19a1f7ee73d70cd1be501c7caa76114892f5b905dc1139d56826b4e
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 KB
Contents
module NudgeGP # A Batch is simply an Array of Answers, with validation for all assignment methods class Batch < Array def self.[](*args) raise ArgumentError unless args.inject(true) {|anded, a| anded & a.kind_of?(Answer)} super end def []=(index, obj) raise ArgumentError unless obj.kind_of?(Answer) super end def <<(obj) raise ArgumentError unless obj.kind_of?(Answer) super end def initialize(*args) raise ArgumentError unless args.inject(true) {|anded, a| anded & a.kind_of?(Answer)} super end def bulk_save!(couchdb_uri) raise ArgumentError, "#{couchdb_uri} is not a String" unless couchdb_uri.kind_of?(String) db = CouchRest.database!(couchdb_uri) db.bulk_save(self.data) end def self.load_tagged_answers(couchdb_uri, tag) raise ArgumentError, "#{couchdb_uri} is not a String" unless couchdb_uri.kind_of?(String) raise ArgumentError, "#{tag} is not a String" unless tag.kind_of?(String) db = CouchRest.database(couchdb_uri) # add the view document and key here return Batch.new end def data self.collect {|i| i.data} end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
answer-factory-0.0.3 | lib/answers/batch.rb |
answer-factory-0.0.2 | lib/answers/batch.rb |
answer-factory-0.0.1 | lib/answers/batch.rb |