Module: Nanite::Actor::ClassMethods

Defined in:
lib/nanite/actor.rb

Overview

self.included

Instance Method Summary collapse

Instance Method Details

#default_prefixObject



25
26
27
# File 'lib/nanite/actor.rb', line 25

def default_prefix
  to_s.to_const_path
end

#expose(*meths) ⇒ Object



29
30
31
32
33
34
# File 'lib/nanite/actor.rb', line 29

def expose(*meths)
  @exposed ||= []
  meths.each do |meth|
    @exposed << meth unless @exposed.include?(meth)
  end
end

#instance_exception_callbackObject



55
56
57
# File 'lib/nanite/actor.rb', line 55

def instance_exception_callback
  @instance_exception_callback
end

#on_exception(proc = nil, &blk) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/nanite/actor.rb', line 41

def on_exception(proc = nil, &blk)
  raise 'No callback provided for on_exception' unless proc || blk
  if Nanite::Actor == self
    raise 'Method name callbacks cannot be used on the Nanite::Actor superclass' if Symbol === proc || String === proc
    @superclass_exception_callback = proc || blk
  else
    @instance_exception_callback = proc || blk
  end
end

#provides_for(prefix) ⇒ Object



36
37
38
39
# File 'lib/nanite/actor.rb', line 36

def provides_for(prefix)
  return [] unless @exposed
  @exposed.map {|meth| "/#{prefix}/#{meth}".squeeze('/')}
end

#superclass_exception_callbackObject



51
52
53
# File 'lib/nanite/actor.rb', line 51

def superclass_exception_callback
  @superclass_exception_callback
end