Sha256: e192d3e3e52acf2f53ae2f5be3ec917d6cfa425a19c05a9bb2036dc49ac28662

Contents?: true

Size: 750 Bytes

Versions: 1

Compression:

Stored size: 750 Bytes

Contents

module Magent
  module Actor
    def self.included(klass)
      klass.class_eval do
        extend Actor::ClassMethods
      end
    end

    module ClassMethods
      def expose(*methods)
        methods.each do |m|
          actions << m.to_s
        end
      end

      def actions
        @actions ||= Set.new
      end

      def can_handle?(action)
        return false if @actions.nil?
        @actions.include?(action.to_s)
      end

      def channel
        @channel ||= begin
          channel_name = "/"+Magent::Utils.underscore(self.name)
          Channel.new(channel_name)
        end
      end
    end
  end # Actor

  def self.register(actor)
    @current_actor = actor
  end

  def self.current_actor
    @current_actor
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
magent-0.0.1 lib/magent/actor.rb