Class: CaTissue::SpecimenRequirement

Inherits:
Object
  • Object
show all
Defined in:
lib/catissue/domain/specimen_requirement.rb

Overview

The SpecimenRequirement domain class.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_requirement(type, event, params = Hash::EMPTY_HASH) ⇒ Object

Creates a SpecimenRequirement of the given subclass type for the given CollectionProtocolEvent event. The type is a SpecimenRequirement subclass name without the SpecimenRequirement suffix, e.g. Tissue. Lower-case, underscore symbols are supported and preferred, e.g. the :tissue type creates a TissueSpecimenRequirement.

The optional params argument are attribute => value associations, e.g.

SpecimenRequirement.create_requirement(:tissue, event, :specimen_type => 'RNA')


80
81
82
83
84
85
86
87
88
89
# File 'lib/catissue/domain/specimen_requirement.rb', line 80

def self.create_requirement(type, event, params=Hash::EMPTY_HASH)
  # make the class name by joining the camel-cased type prefix to the subclass suffix
  class_name = type.to_s.classify + self.qp
  begin
    klass = CaTissue.const_get(class_name)
  rescue
    raise ArgumentError.new("Unsupported requirement type: #{type}; #{class_name} must be a subtype of #{self}")
  end
  klass.new(params.merge(:collection_protocol_event => event))
end

Instance Method Details

#collection_protocolCaTissue::CollectionProtocol

Returns the collection event protocol, if any.

Returns:



92
93
94
# File 'lib/catissue/domain/specimen_requirement.rb', line 92

def collection_protocol
  collection_event.protocol if collection_event
end

#match_in_owner_scope(others) ⇒ Object

Returns the SpecimenRequirement in others which matches this SpecimenRequirement in the scope of an owner CollectionProtocolEvent. This method relaxes Jinx::Resource.match_in_owner_scope for a SpecimenRequirement that matches any SpecimenRequirement in others with the same class, specimen type, pathological_status and characteristics.



49
50
51
52
53
54
# File 'lib/catissue/domain/specimen_requirement.rb', line 49

def match_in_owner_scope(others)
  others.detect do |other|
    self.class == other.class and specimen_type == other.specimen_type and pathological_status == other.pathological_status and
     characteristics and characteristics.matches?(other.characteristics)
  end
end

#updatable?Boolean

Returns false.

Returns:

  • (Boolean)

    false



40
41
42
# File 'lib/catissue/domain/specimen_requirement.rb', line 40

def updatable?
  false
end