Module: Hyrax::WithEvents

Included in:
FileSetBehavior, FileSetPresenter, Resource, WorkBehavior
Defined in:
app/models/concerns/hyrax/with_events.rb

Overview

A mixin module intended to provide an interface into creating the paper trail of activity on the target model of the mixin.

See Also:

Instance Method Summary collapse

Instance Method Details

#event_classString

Returns:

  • (String)


13
14
15
# File 'app/models/concerns/hyrax/with_events.rb', line 13

def event_class
  model_name.name
end

#events(size = -1)) ⇒ Object

Parameters:

  • size (Integer) (defaults to: -1))

    the maximum number of events to fetch from the log. Offset by 1; to get one event, use ‘0`, for two, use `1`, etc… `-1` gives all events.



21
22
23
# File 'app/models/concerns/hyrax/with_events.rb', line 21

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

#log_event(event_id) ⇒ Object



25
26
27
# File 'app/models/concerns/hyrax/with_events.rb', line 25

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

#streamObject



8
9
10
# File 'app/models/concerns/hyrax/with_events.rb', line 8

def stream
  Nest.new(event_class)[to_param]
end