Sha256: c7417dd9bbf95b3b00d1548c3648e39fc709d6f5ff3d27421cccdef4db51224e

Contents?: true

Size: 705 Bytes

Versions: 1

Compression:

Stored size: 705 Bytes

Contents

module Couchbase

  class DesignDocFormatError < Error::Base; end

  class DesignDoc

    java_import com.couchbase.client.java.view.DesignDocument
    java_import com.couchbase.client.java.view.DefaultView

    def initialize(name, design_doc)
      @name  = name
      @views = java.util.ArrayList.new
      design_doc.each_pair do |view_name, view|
        if view.key?(:reduce)
          @views.add DefaultView.create(view_name.to_s, view[:map], view[:reduce])
        else
          @views.add DefaultView.create(view_name.to_s, view[:map])
        end
      end
    rescue => e
      raise DesignDocFormatError, e
    end

    def create
      DesignDocument.create(@name, @views)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
couchbase-jruby-client-1.0.4-java lib/couchbase/design_doc.rb