Class: ResourceStateEventFinder

Inherits:
Object
  • Object
show all
Includes:
FinderMethods
Defined in:
app/finders/resource_state_event_finder.rb

Instance Method Summary collapse

Methods included from FinderMethods

#find, #find_by, #find_by!

Constructor Details

#initialize(current_user, eventable) ⇒ ResourceStateEventFinder

Returns a new instance of ResourceStateEventFinder.


6
7
8
9
# File 'app/finders/resource_state_event_finder.rb', line 6

def initialize(current_user, eventable)
  @current_user = current_user
  @eventable = eventable
end

Instance Method Details

#can_read_eventable?Boolean

Returns:

  • (Boolean)

17
18
19
20
21
# File 'app/finders/resource_state_event_finder.rb', line 17

def can_read_eventable?
  return unless eventable

  Ability.allowed?(current_user, read_ability, eventable)
end

#executeObject


11
12
13
14
15
# File 'app/finders/resource_state_event_finder.rb', line 11

def execute
  return ResourceStateEvent.none unless can_read_eventable?

  eventable.resource_state_events.includes(:user) # rubocop: disable CodeReuse/ActiveRecord
end