module Hyrax
  # A mixin module intended to provide an interface into creating the paper trail
  # of activity on the target model of the mixin.
  #
  # @see Hyrax::Event
  module WithEvents
    def stream
      Nest.new(event_class)[to_param]
    end

    # @return [String]
    def event_class
      self.class.name
    end

    def events(size = -1)
      event_stream.fetch(size)
    end

    def log_event(event_id)
      event_stream.push(event_id)
    end

    private

      def event_store
        RedisEventStore
      end

      def event_stream
        event_store.for(stream[:event])
      end
  end
end

module Hyrax
  # A mixin module intended to provide an interface into creating the paper trail
  # of activity on the target model of the mixin.
  #
  # @see Hyrax::Event
  module WithEvents
    def stream
      Nest.new(event_class)[to_param]
    end

    # @return [String]
    def event_class
      model_name.name
    end

    def events(size = -1)
      event_stream.fetch(size)
    end

    def log_event(event_id)
      event_stream.push(event_id)
    end

    private

      def event_store
        RedisEventStore
      end

      def event_stream
        event_store.for(stream[:event])
      end
  end
end

Use `model_name.name` for event class namespacing
Use `model_name.name` for event class namespacing

Pin the namespacing for events to the model name, not the Ruby class name. In
most cases (excepting adopters who have specificially overridden ActiveModel
naming behavior) this should have no impact, but loosens the dependency on
specific Ruby class names.
