Sha256: a5874b8da17c6c6ff8bb57f18bca363c0df9a5389326153ad4d28894ded9092d

Contents?: true

Size: 1.57 KB

Versions: 7

Compression:

Stored size: 1.57 KB

Contents

module ExampleActorClass
  def self.create(included_module)
    Class.new do
      include included_module
      attr_reader :name

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

      def change_name(new_name)
        @name = new_name
      end

      def change_name_with_a_bang(new_name)
        change_name! new_name
      end

      def change_name_async(new_name)
        async.change_name new_name
      end

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

      def run(*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 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
        zomg_private!
      end

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

      private

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
celluloid-0.12.3 spec/support/example_actor_class.rb
celluloid-0.12.2 spec/support/example_actor_class.rb
celluloid-0.12.1 spec/support/example_actor_class.rb
celluloid-0.12.1.pre2 spec/support/example_actor_class.rb
celluloid-0.12.1.pre spec/support/example_actor_class.rb
celluloid-0.12.0 spec/support/example_actor_class.rb
celluloid-0.12.0.pre3 spec/support/example_actor_class.rb