module ExampleActorClass - celluloid-0.16.0 Documentation

# module ExampleActorClass

### Public Class Methods

create(included_module, task_klass) click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 2
    def self.create(included_module, task_klass)
      Class.new do
        include included_module
        task_class task_klass
        attr_reader :name
        finalizer :my_finalizer
        execute_block_on_receiver :run_on_receiver

        def initialize(name)
          @name = name
          @delegate = [:bar]
        end

        def sleepy(duration)
          sleep duration
        end

        def change_name(new_name)
          @name = new_name
        end

        def change_name_async(new_name)
          async.change_name new_name
        end

        def greet
          "Hi, I'm #{@name}"
        end

        def actor?
          Celluloid.actor?
        end

        def run(*args)
          yield(*args)
        end

        def run_on_receiver(*args)
          yield(*args)
        end

        def crash
          raise ExampleCrash, "the spec purposely crashed me :("
        end

        def crash_with_abort(reason, foo = nil)
          example_crash = ExampleCrash.new(reason)
          example_crash.foo = foo
          abort example_crash
        end

        def crash_with_abort_raw(reason)
          abort reason
        end

        def internal_hello
          external_hello
        end

        def external_hello
          "Hello"
        end

        def inspect_thunk
          inspect
        end

        def send(string)
          string.reverse
        end

        def shutdown
          terminate
        end

        def method_missing(method_name, *args, &block)
          if delegates?(method_name)
            @delegate.send method_name, *args, &block
          else
            super
          end
        end

        def respond_to?(method_name, include_private = false)
          super || delegates?(method_name)
        end

        def call_private
          async.zomg_private
        end

        def zomg_private
          @private_called = true
        end
        private :zomg_private
        attr_reader :private_called

        def my_finalizer
        end

        private

        def delegates?(method_name)
          @delegate.respond_to?(method_name)
        end
      end
    end

new(name) click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 10
    def initialize(name)
      @name = name
      @delegate = [:bar]
    end

### Public Instance Methods

actor?() click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 31
    def actor?
      Celluloid.actor?
    end

call_private() click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 89
    def call_private
      async.zomg_private
    end

change_name(new_name) click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 19
    def change_name(new_name)
      @name = new_name
    end

change_name_async(new_name) click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 23
    def change_name_async(new_name)
      async.change_name new_name
    end

crash() click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 43
    def crash
      raise ExampleCrash, "the spec purposely crashed me :("
    end

crash_with_abort(reason, foo = nil) click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 47
    def crash_with_abort(reason, foo = nil)
      example_crash = ExampleCrash.new(reason)
      example_crash.foo = foo
      abort example_crash
    end

crash_with_abort_raw(reason) click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 53
    def crash_with_abort_raw(reason)
      abort reason
    end

delegates?(method_name) click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 104
    def delegates?(method_name)
      @delegate.respond_to?(method_name)
    end

external_hello() click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 61
    def external_hello
      "Hello"
    end

greet() click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 27
    def greet
      "Hi, I'm #{@name}"
    end

inspect_thunk() click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 65
    def inspect_thunk
      inspect
    end

internal_hello() click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 57
    def internal_hello
      external_hello
    end

method_missing(method_name, *args, &block) click to toggle source
Calls superclass method

    # File lib/celluloid/rspec/example_actor_class.rb, line 77
    def method_missing(method_name, *args, &block)
      if delegates?(method_name)
        @delegate.send method_name, *args, &block
      else
        super
      end
    end

my_finalizer() click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 99
    def my_finalizer
    end

respond_to?(method_name, include_private = false) click to toggle source
Calls superclass method

    # File lib/celluloid/rspec/example_actor_class.rb, line 85
    def respond_to?(method_name, include_private = false)
      super || delegates?(method_name)
    end

run(*args) { |*args| ... } click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 35
    def run(*args)
      yield(*args)
    end

run_on_receiver(*args) { |*args| ... } click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 39
    def run_on_receiver(*args)
      yield(*args)
    end

send(string) click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 69
    def send(string)
      string.reverse
    end

shutdown() click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 73
    def shutdown
      terminate
    end

sleepy(duration) click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 15
    def sleepy(duration)
      sleep duration
    end

zomg_private() click to toggle source

    # File lib/celluloid/rspec/example_actor_class.rb, line 93
    def zomg_private
      @private_called = true
    end