Module: CaTissue::Collectible
- Included in:
- Specimen, SpecimenCollectionGroup
- Defined in:
- lib/catissue/helpers/collectible.rb
Overview
A Collectible mix-in instance can hold CollectibleEventParameters}.
Instance Method Summary collapse
-
#collect(opts) ⇒ Object
Collects and receives this Collectible with the given options.
-
#collected? ⇒ Boolean
Whether this Collectible has a collected event.
-
#collectible_event_parameters ⇒ Object
Returns the CollectibleEventParameters for this Collectible.
-
#collection_event_parameters ⇒ Object
Returns the CollectionEventParameters for this Collectible.
-
#collection_timestamp ⇒ Date
The date this Collectible was donated by the participant.
-
#collector ⇒ Object
Returns the User who collected this Collectible.
-
#merge_attributes(other, attributes = nil, matches = nil, &filter) ⇒ Object
Augments Jinx::Resource#merge_attributes to builds this collectible domain object’s SpecimenEventParameters.
-
#received? ⇒ Boolean
Returns whether this Collectible has a received event.
-
#received_event_parameters ⇒ Object
Returns the ReceivedEventParameters for this Collectible.
-
#receiver ⇒ Object
Returns the User who received this Collectible.
Instance Method Details
#collect(opts) ⇒ Object
Collects and receives this Collectible with the given options.
36 37 38 39 |
# File 'lib/catissue/helpers/collectible.rb', line 36 def collect(opts) raise Jinx::ValidationError.new("#{self} is already collected") if received? specimen_event_parameters.merge!(extract_event_parameters(opts)) end |
#collected? ⇒ Boolean
Returns whether this Collectible has a collected event.
42 43 44 |
# File 'lib/catissue/helpers/collectible.rb', line 42 def collected? collection_event_parameters end |
#collectible_event_parameters ⇒ Object
Returns the CaTissue::CollectibleEventParameters for this Collectible.
64 65 66 |
# File 'lib/catissue/helpers/collectible.rb', line 64 def collectible_event_parameters event_parameters.select { |ep| CaTissue::CollectibleEventParameters === ep } end |
#collection_event_parameters ⇒ Object
Returns the CollectionEventParameters for this Collectible.
59 60 61 |
# File 'lib/catissue/helpers/collectible.rb', line 59 def collection_event_parameters event_parameters.detect { |ep| CaTissue::CollectionEventParameters === ep } end |
#collection_timestamp ⇒ Date
Returns the date this Collectible was donated by the participant.
53 54 55 56 |
# File 'lib/catissue/helpers/collectible.rb', line 53 def ep = collection_event_parameters ep. if ep end |
#collector ⇒ Object
Returns the User who collected this Collectible.
47 48 49 50 |
# File 'lib/catissue/helpers/collectible.rb', line 47 def collector ep = collection_event_parameters ep.user if ep end |
#merge_attributes(other, attributes = nil, matches = nil, &filter) ⇒ Object
Augments Jinx::Resource#merge_attributes to builds this collectible domain object’s SpecimenEventParameters. If the other source object is a Hash, then it includes both the standard attribute => value associations as well as the options described below.
22 23 24 25 26 27 28 29 |
# File 'lib/catissue/helpers/collectible.rb', line 22 def merge_attributes(other, attributes=nil, matches=nil, &filter) if Hash === other then # extract the event parameters other[:specimen_event_parameters] = extract_event_parameters(other) end # delegate to super for standard attribute value merge super end |
#received? ⇒ Boolean
Returns whether this Collectible has a received event.
69 70 71 |
# File 'lib/catissue/helpers/collectible.rb', line 69 def received? received_event_parameters end |
#received_event_parameters ⇒ Object
Returns the ReceivedEventParameters for this Collectible.
80 81 82 |
# File 'lib/catissue/helpers/collectible.rb', line 80 def received_event_parameters event_parameters.detect { |ep| CaTissue::ReceivedEventParameters === ep } end |
#receiver ⇒ Object
Returns the User who received this Collectible.
74 75 76 77 |
# File 'lib/catissue/helpers/collectible.rb', line 74 def receiver ep = received_event_parameters ep.user if ep end |