Module: Bumbleworks::WorkitemEntityStorage
- Included in:
- ErrorHandler, LocalParticipant, Task
- Defined in:
- lib/bumbleworks/workitem_entity_storage.rb
Defined Under Namespace
Classes: EntityNotFound
Instance Method Summary collapse
- #entity(options = {}) ⇒ Object
- #entity_fields(options = {}) ⇒ Object
- #has_entity? ⇒ Boolean
- #has_entity_fields? ⇒ Boolean
Instance Method Details
#entity(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/bumbleworks/workitem_entity_storage.rb', line 5 def entity( = {}) @entity = nil if [:reload] == true @entity ||= if has_entity_fields? klass = Bumbleworks::Support.constantize(entity_type) entity = klass.first_by_identifier(entity_id) end raise EntityNotFound, {:entity_id => entity_id, :entity_type => entity_type} unless @entity @entity end |
#entity_fields(options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bumbleworks/workitem_entity_storage.rb', line 25 def entity_fields( = {}) return {} unless has_entity_fields? type = if [:humanize] == true Bumbleworks::Support.humanize(entity_type) elsif [:titleize] == true Bumbleworks::Support.titleize(entity_type) else entity_type end { :type => type, :identifier => entity_id } end |
#has_entity? ⇒ 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
21 22 23 |
# File 'lib/bumbleworks/workitem_entity_storage.rb', line 21 def has_entity_fields? entity_id && entity_type end |