Class: Yinx::SQL::Batch
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Yinx::SQL::Batch
- Defined in:
- lib/yinx_sql/batch.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.insert(notes) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/yinx_sql/batch.rb', line 11 def self.insert notes batch = Batch.new = Hash.new do |h, name| tag = Tag.new name: name batch. << tag h[name] = tag end notes.each do |note| n = Note.new(title: note.title, book: note.book, stack: note.stack, content_length: note.contentLength, created_at: note.created_at, updated_at: note.updated_at) batch.notes << n note..each do |tag_name| tag = [tag_name] tag.notes << n end end batch.save end |
Instance Method Details
#books ⇒ Object
39 40 41 |
# File 'lib/yinx_sql/batch.rb', line 39 def books notes.map(&:stack_book).uniq end |
#stacks ⇒ Object
43 44 45 |
# File 'lib/yinx_sql/batch.rb', line 43 def stacks notes.map{|note| note.stack.nil? ? 'NO_STACK' : note.stack}.uniq end |