Sha256: a0abd751f1e24b8fba09bd0d1c680e2b8e105a6dc2381b8b81e444baf681fa3a

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 KB

Contents

module Gom
  module Remote
    class Subscription
      
      Defaults = {
        :name             => nil,
        :operations       => [:update],
        :condition_script => nil, 
        :uri_regexp       => nil,
        :callback         => nil, 
      }

      attr_reader :entry_uri, :uri, :callback
      attr_accessor :callback
      attr_reader :name, :operations, :condition_script, :uri_regexp

      def to_s
        "#{self.class}: #{@options.inject}"
      end

      # hint: supplying a recognizable name helps with distributed gom
      # operations 
      #
      def initialize entry_uri, options = {}, &blk
        @name = options[:name] || "0x#{object_id}"
        # URI for the observer node 
        @uri = "/gom/observer#{entry_uri.sub ':', '/'}/.#{@name}"

        @options = Defaults.merge options
        @entry_uri = entry_uri
        @callback = options[:callback] || blk;
        @operations = (@options[:operations] || []).join ', '
        @uri_regexp = (re = @options[:uri_regexp]) && (Regexp.new re) || nil
        @condition_script = @options[:condition_script]
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gom-script-0.2.2 lib/gom/remote/subscription.rb
gom-script-0.2.0 lib/gom/remote/subscription.rb
gom-script-0.1.6 lib/gom/remote/subscription.rb
gom-script-0.1.5 lib/gom/remote/subscription.rb
gom-script-0.1.4 lib/gom/remote/subscription.rb
gom-script-0.1.3 lib/gom/remote/subscription.rb
gom-script-0.1.2 lib/gom/remote/subscription.rb