Sha256: 50a30a355b4d0856628297349f1d4ddeeb61562e9b5e0d195fa2cdf4ca3989e7

Contents?: true

Size: 639 Bytes

Versions: 1

Compression:

Stored size: 639 Bytes

Contents

module Recliner
  class ViewDocument < Recliner::Document
    property :language, String, :default => 'javascript'
    property :views, Map(String => View)
    
    def update_views(new_views)
      self.views = views.dup.replace(new_views)
      save! if changed?
    end
    
    def invoke(view, *args)
      views[view].invoke(database, "#{id}/_view/#{view}", *args)
    rescue DocumentNotFound
      # The view disappeared from the database while we were working with the view document.
      # Reset the revision, save the view document, and try to invoke the view again.
      self.rev = nil
      save! and retry
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
recliner-0.0.1 lib/recliner/views/document.rb