Module: Nanite::Actor::ClassMethods
- Defined in:
- lib/nanite/actor.rb
Overview
self.included
Instance Method Summary collapse
- #default_prefix ⇒ Object
- #exception_callback ⇒ Object
- #expose(*meths) ⇒ Object
- #on_exception(proc = nil, &blk) ⇒ Object
- #provides_for(prefix) ⇒ Object
Instance Method Details
#default_prefix ⇒ Object
25 26 27 |
# File 'lib/nanite/actor.rb', line 25 def default_prefix to_s.to_const_path end |
#exception_callback ⇒ Object
53 54 55 |
# File 'lib/nanite/actor.rb', line 53 def exception_callback @exception_callback 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 |
#on_exception(proc = nil, &blk) ⇒ Object
48 49 50 51 |
# File 'lib/nanite/actor.rb', line 48 def on_exception(proc = nil, &blk) raise 'No callback provided for on_exception' unless proc || blk @exception_callback = proc || blk end |
#provides_for(prefix) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/nanite/actor.rb', line 36 def provides_for(prefix) return [] unless @exposed @exposed.select do |meth| if instance_methods.include?(meth.to_s) or instance_methods.include?(meth.to_sym) true else Nanite::Log.warn("Exposing non-existing method #{meth} in actor #{name}") false end end.map {|meth| "/#{prefix}/#{meth}".squeeze('/')} end |