Class: Gom::Remote::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/gom/remote/subscription.rb

Constant Summary collapse

Defaults =
{
  :name             => nil,
  :operations       => [:update],
  :condition_script => nil, 
  :uri_regexp       => nil,
  :callback         => nil, 
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entry_uri, options = {}, &blk) ⇒ Subscription

hint: supplying a recognizable name helps with distributed gom operations



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/gom/remote/subscription.rb', line 24

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

Instance Attribute Details

#callbackObject

Returns the value of attribute callback.



13
14
15
# File 'lib/gom/remote/subscription.rb', line 13

def callback
  @callback
end

#condition_scriptObject (readonly)

Returns the value of attribute condition_script.



15
16
17
# File 'lib/gom/remote/subscription.rb', line 15

def condition_script
  @condition_script
end

#entry_uriObject (readonly)

Returns the value of attribute entry_uri.



13
14
15
# File 'lib/gom/remote/subscription.rb', line 13

def entry_uri
  @entry_uri
end

#nameObject (readonly)

Returns the value of attribute name.



15
16
17
# File 'lib/gom/remote/subscription.rb', line 15

def name
  @name
end

#operationsObject (readonly)

Returns the value of attribute operations.



15
16
17
# File 'lib/gom/remote/subscription.rb', line 15

def operations
  @operations
end

#uriObject (readonly)

Returns the value of attribute uri.



13
14
15
# File 'lib/gom/remote/subscription.rb', line 13

def uri
  @uri
end

#uri_regexpObject (readonly)

Returns the value of attribute uri_regexp.



15
16
17
# File 'lib/gom/remote/subscription.rb', line 15

def uri_regexp
  @uri_regexp
end

Instance Method Details

#to_sObject



17
18
19
# File 'lib/gom/remote/subscription.rb', line 17

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