Module: Bumbleworks::WorkitemEntityStorage

Included in:
LocalParticipant, Task
Defined in:
lib/bumbleworks/workitem_entity_storage.rb

Defined Under Namespace

Classes: EntityNotFound

Instance Method Summary collapse

Instance Method Details

#entity(options = {}) ⇒ Object

Raises:



5
6
7
8
9
10
11
12
13
# File 'lib/bumbleworks/workitem_entity_storage.rb', line 5

def entity(options = {})
  @entity = nil if options[:reload] == true
  @entity ||= if has_entity_fields?
    klass = Bumbleworks::Support.constantize(workitem.fields['entity_type'])
    entity = klass.first_by_identifier(workitem.fields['entity_id'])
  end
  raise EntityNotFound unless @entity
  @entity
end

#has_entity?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
# File 'lib/bumbleworks/workitem_entity_storage.rb', line 15

def has_entity?
  !entity.nil?
rescue EntityNotFound
  false
end

#has_entity_fields?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/bumbleworks/workitem_entity_storage.rb', line 21

def has_entity_fields?
  workitem.fields['entity_id'] && workitem.fields['entity_type']
end