Sha256: 4155bc2b4026085ae0aeaa68e9efe898e32ca860bcf51056e1b84f6def57c97c

Contents?: true

Size: 1.97 KB

Versions: 15

Compression:

Stored size: 1.97 KB

Contents

module ExampleActorClass
  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
end

Version data entries

15 entries across 13 versions & 5 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/celluloid-0.16.0/lib/celluloid/rspec/example_actor_class.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/celluloid-0.16.0/lib/celluloid/rspec/example_actor_class.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/celluloid-0.16.0/lib/celluloid/rspec/example_actor_class.rb
scoot-0.0.4 .bundle/gems/ruby/2.2.0/gems/celluloid-0.16.0/lib/celluloid/rspec/example_actor_class.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/celluloid-0.16.0/lib/celluloid/rspec/example_actor_class.rb
celluloid-0.16.0 lib/celluloid/rspec/example_actor_class.rb
celluloid-0.16.0.pre3 spec/support/example_actor_class.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/celluloid-0.15.2/spec/support/example_actor_class.rb
celluloid-0.16.0.pre2 spec/support/example_actor_class.rb
celluloid-0.16.0.pre spec/support/example_actor_class.rb
celluloid-0.15.2 spec/support/example_actor_class.rb
celluloid-0.15.1 spec/support/example_actor_class.rb
celluloid-0.15.0 spec/support/example_actor_class.rb
celluloid-0.15.0.pre2 spec/support/example_actor_class.rb
celluloid-0.15.0.pre spec/support/example_actor_class.rb