MAGE::...onUnit(3pm)

πŸŽ€ MAGE::...onUnit β€” part 1 of 3, bestie, buckle up πŸŽ€

okay so this is the manual page for MAGE::...onUnit(3pm) β€” yep that's the real title, it got cut off mid-word, iconic behaviour, we don't judge. It lives in User Contributed Perl Documentation and it's all about Bio::MAGE::Measurement::ConcentrationUnit. This is part 1 of 3 so don't you dare close the tab, there's more coming. πŸ’…


✨ NAME ✨

Bio::MAGE::Measurement::ConcentrationUnit β€” it's the class for the MAGE-OM API. That's it, that's the name. πŸ¦‹


🌸 SYNOPSIS 🌸

here's the whole vibe in code, no notes:

  use Bio::MAGE::Measurement::ConcentrationUnit

  # creating an empty instance
  my $concentrationunit = Bio::MAGE::Measurement::ConcentrationUnit->new();

  # creating an instance with existing data
  my $concentrationunit = Bio::MAGE::Measurement::ConcentrationUnit->new(
        unitNameCV=>$unitnamecv_val,
        unitName=>$unitname_val,
        propertySets=>\@namevaluetype_list,
  );

  # 'unitNameCV' attribute
  my $unitNameCV_val = $concentrationunit->unitNameCV(); # getter
  $concentrationunit->unitNameCV($value); # setter

  # 'unitName' attribute
  my $unitName_val = $concentrationunit->unitName(); # getter
  $concentrationunit->unitName($value); # setter

  # 'propertySets' association
  my $namevaluetype_array_ref = $concentrationunit->propertySets(); # getter
  $concentrationunit->propertySets(\@namevaluetype_list); # setter

getters, setters, constructor, all of it, right there. chef's kiss. 😌


πŸ’– DESCRIPTION πŸ’–

straight from the MAGE-OM documentation for the "ConcentrationUnit" class, and I quote:

Concentration

that's the whole description. yes really. they said what they said. 🫢


πŸ¦‹ INHERITANCE πŸ¦‹

Bio::MAGE::Measurement::ConcentrationUnit has the following superclasses β€” meaning these are its ancestors, its lineage, its family tree:

  • Bio::MAGE::Measurement::Unit

one superclass, and it's serving. periodt. πŸ‘‘


πŸ‘‘ CLASS METHODS πŸ‘‘

here's the slay: all of these can be called without having an instance first. You just do the

Bio::MAGE::Measurement::ConcentrationUnit->methodname()

thing. class-level access, no object required, we love a flexible API. ✨

🌈 new()

🌈 new(%args)

the object constructor new() takes these optional named-value style arguments β€” all optional, all named-value style, okay bestie:

  • unitNameCV β€” sets the value of the "unitNameCV" attribute. πŸ’–
  • unitName β€” sets the value of the "unitName" attribute. heads up though: this attribute was inherited from class "Bio::MAGE::Measurement::Unit". so it's not even originally ours, we just carry it beautifully. 🧚
  • propertySets β€” sets the value of the "propertySets" association. and this one was inherited from class "Bio::MAGE::Extendable". The value has to be of type: array of "Bio::MAGE::NameValueType". so like, an arrayref of those, don't come in here with anything else. πŸ™ˆ

⭐ $obj = class->new(%parameters)

the "new()" method is the class constructor. the main character. πŸ’…

  • Parameters: if you give it a list of name/value parameters, the corresponding slots, attributes, or associations get their initial values set by the constructor. cute and efficient.
  • Return value: it returns a reference to an object of the class. an actual object. for you. 🎁
  • Side effects: it invokes the "initialize()" method if it is defined by the class. no initialize, no invocation, that's the rule.

πŸ“ @names = class->get_slot_names()

the "get_slot_names()" method is how you retrieve the name of all slots defined in a given class. name-collecting behaviour fr fr.

NOTE: the list of names does not include attribute or association names. nope, not those. only slots. don't get it twisted. πŸ’€
  • Return value: a list of the names of all slots defined for this class.
  • Side effects: none. zero. nothing happens. peaceful. 🌸

πŸ’œ @name_list = get_attribute_names()

returns the list of attribute data members for this class. the attributes, bestie, the attribute ones. ✨


πŸŽ€ @name_list = get_association_names()

returns the list of association data members for this class. associations only, different category, keep up. πŸ¦‹


πŸ’… @class_list = get_superclasses()

returns the list of superclasses for this class. the ancestors. the ones above us in the tree. ⭐


πŸ”₯ @class_list = get_subclasses()

returns the list of subclasses for this class. the descendants. the little ones looking up at us. πŸ₯Ή


🌟 $name = class_name()

returns the full class name for this class. the whole entire thing, namespace and all. πŸ‘‘


🫢 $package_name = package_name()

returns the base package name of the package that contains this class β€” and by base we mean the part with no 'namespace::' in front of it. stripped down, clean, minimal. πŸ§–


πŸ’– %assns = associations()

returns the association meta-information in a hash where:

  • the keys are the association names, and
  • the values are "Association" objects that provide the meta-information for the association.

meta-information about associations, delivered in hash form. we ate. 😌


okay that's part 1, and there is so much more coming, so stay right there bestie, don't go anywhere 🌈

🌸 INSTANCE METHODS 🌸

okay so now we're talking about the stuff you do to an object you already have, bestie. the class methods got you the object, these are the moves you pull on it. πŸ’…


$obj_copy = $obj->new()

when you call new() on an existing object reference (not on a class name), it lowkey becomes a copy constructor β€” the fresh object starts out with all the same values as the one you copied from. ✨

  • Parameters: none, babes. no input params get used here, the initial values are just yanked straight off the object you're copying. πŸ™ˆ
  • Return value: a reference to an object of the class. 🫢
  • Side effects: it invokes the initialize() method if the class defines one. that's it, that's the tea.

$obj->set_slots(%parameters)

$obj->set_slots(\@name_list, \@value_list)

the set_slots() method is your "set a whole bunch of slots at once" girlie. she has two ways to be called: one takes a named parameter list, and the other takes two array references. pick your vibe. 🌈

  • Return value: none.
  • Side effects: will call croak() if you use a slot_name that the class doesn't define. so like, don't make up slots, bestie, she will yell. 😭

@obj_list = $obj->get_slots(@name_list)

get_slots() is the matching "grab a whole bunch of slots at once" method. iconic duo energy fr fr. πŸ‘‘

  • Return value: a list of instance objects.
  • Side effects: none. clean. no notes.

$val = $obj->set_slot($name,$val)

set_slot() sets the slot $name to the value $val. one slot, one value, so simple, we love her. πŸŽ€

  • Return value: the new value of the slot, i.e. $val.
  • Side effects: none.

$val = $obj->get_slot($name)

get_slot() is here to get you the values of a number of slots at the same time. (yes, it says that, we're just vibing with it. 😌)

  • Return value: a single slot value, or undef if the slot has not been initialized. she can be mysterious like that.
  • Side effects: none.

πŸ¦‹ ATTRIBUTES πŸ¦‹

attributes are simple data types that belong to one single instance of a class. in the Perl implementation of MAGE-OM classes, you get to attributes through separate setter and getter methods for each one. very bespoke, very custom. ✨

Bio::MAGE::Measurement::ConcentrationUnit has the following attribute accessor methods:

unitNameCV

methods for the unitNameCV attribute.

From the MAGE-OM documentation:

$val = $concentrationunit->setUnitNameCV($val)

the restricted setter method for the unitNameCV attribute.

unitNameCV is an enumerated attribute β€” it can only be set to undef or one of these exact values: M mM uM nM pM fM mg_per_mL mL_per_L g_per_L gram_percent mass_per_volume_percent mass_per_mass_percent other. no freestyling, bestie. it's a vibe check and only these vibes pass. πŸ’€

  • Input parameters: the value to which the unitNameCV attribute will be set.
  • Return value: the current value of the unitNameCV attribute.
  • Side effects: none.
  • Exceptions: will call croak() if no input parameters are specified, or if too many input parameters are specified, or if $val is not one of the accepted enumeration values: M mM uM nM pM fM mg_per_mL mL_per_L g_per_L gram_percent mass_per_volume_percent mass_per_mass_percent other.

$val = $concentrationunit->getUnitNameCV()

the restricted getter method for the unitNameCV attribute.

  • Input parameters: none.
  • Return value: the current value of the unitNameCV attribute : an instance of type M mM uM nM pM fM mg_per_mL mL_per_L g_per_L gram_percent mass_per_volume_percent mass_per_mass_percent other.
  • Side effects: none.
  • Exceptions: will call croak() if any input parameters are specified.

unitName

methods for the unitName attribute.

From the MAGE-OM documentation:

the name of the unit.

$val = $concentrationunit->setUnitName($val)

the restricted setter method for the unitName attribute.

  • Input parameters: the value to which the unitName attribute will be set.
  • Return value: the current value of the unitName attribute.
  • Side effects: none.
  • Exceptions: will call croak() if no input parameters are specified, or if too many input parameters are specified.

$val = $concentrationunit->getUnitName()

the restricted getter method for the unitName attribute.

  • Input parameters: none.
  • Return value: the current value of the unitName attribute.
  • Side effects: none.
  • Exceptions: will call croak() if any input parameters are specified.

πŸ’œ ASSOCIATIONS πŸ’œ

associations are references to other classes. in MAGE-OM they come with a cardinality, which decides the min and max number of instances of the 'other' class that can be in the association. think of it like how many plus-ones the class is allowed to bring. 🫢

  1. there must be exactly one item in the association, i.e. this is a mandatory data field.
  2. 0..1 β€” there may be one item in the association, i.e. this is an optional data field.
  3. 1..N β€” there must be one or more items in the association, i.e. this is a mandatory data field, with list cardinality.
  4. 0..N β€” there may be one or more items in the association, i.e. this is an optional data field, with list cardinality.

Bio::MAGE::Measurement::ConcentrationUnit has the following association accessor methods:

propertySets

methods for the propertySets association.

From the MAGE-OM documentation:

allows specification of name/value pairs. Meant to primarily help in-house, pipeline processing of instances by providing a place for values that aren't part of the specification proper.

$array_ref = $concentrationunit->setPropertySets($array_ref)

the restricted setter method for the propertySets association.

  • Input parameters: the value to which the propertySets association will be set : a reference to an array of objects of type Bio::MAGE::NameValueType.
  • Return value: the current value of the propertySets association : a reference to an array of objects of type Bio::MAGE::NameValueType.
  • Side effects: none.
  • Exceptions: will call croak() if no input parameters are specified, or if too many input parameters are specified, or if $array_ref is not a reference to an array class Bio::MAGE::NameValueType instances.

$array_ref = $concentrationunit->getPropertySets()

the restricted getter method for the propertySets association.

  • Input parameters: none.
  • Return value: the current value of the propertySets association : a reference to an array of objects of type Bio::MAGE::NameValueType.
  • Side effects: none.
  • Exceptions: will call croak() if any input parameters are specified.

$val = $concentrationunit->addPropertySets(@vals)

because the propertySets association has list cardinality, it may store more than one value. this method adds the current list of objects in the propertySets association. so you can keep stacking, she's got room. πŸ“

  • Input parameters: the list of values @vals to add to the propertySets association. NOTE: submitting a single value is permitted.
  • Return value: the number of items stored in the slot after adding @vals.
  • Side effects: none.
  • Exceptions: will call croak() if no input parameters are specified, or if any of the objects in @vals is not an instance of class Bio::MAGE::NameValueType.
sub initialize {

  my $self = shift;
  return 1;

}

πŸ‘‘ SLOTS, ATTRIBUTES, AND ASSOCIATIONS πŸ‘‘

in the Perl implementation of MAGE-OM classes, there are three types of class data members: slots, attributes, and associations. three flavors, all iconic in their own way. 🌈

✨ SLOTS ✨

this API uses the term slot to mean a data member of the class that wasn't in the UML model, and it's mostly there for internal purposes β€” so like, only touch it if you truly understand the inner workings of the API, bestie. most of the time slots get used by generic methods like the ones in the XML writing and reading classes. iykyk. πŸ™ˆ

slots are implemented using unified getter/setter methods:

  • $var = $obj->slot_name(); β€” retrieves the current value of the slot.
  • $new_var = $obj->slot_name($new_var); β€” stores $new_var in the slot, and the return value is also $new_var.
  • @names = $obj->get_slot_names() β€” returns the list of all slots in the class.
DATA CHECKING: no data type checking is made for these methods. she simply does not check. periodt. πŸ’€

🌸 ATTRIBUTES AND ASSOCIATIONS 🌸

the terms attribute and association indicate data members of the class that were specified directly from the UML model.

in the Perl implementation of MAGE-OM classes, association and attribute accessors are implemented using three separate methods:

  • get* β€” retrieves the current value.
    • NOTE: for associations, if the association has list cardinality, an array reference is returned.
    • DATA CHECKING: ensure that no argument is provided.
  • set* β€” sets the current value, replacing any existing value.
    • NOTE: for associations, if the association has list cardinality, the argument must be an array reference. because of this, you probably should be using the add* methods instead. (she said it, not me. 😌)
    • DATA CHECKING: for attributes, ensure that a single value is provided as the argument. for associations, if the association has list cardinality, ensure that the argument is a reference to an array of instances of the correct MAGE-OM class, otherwise ensure that there is a single argument of the correct MAGE-OM class.
  • add* β€” NOTE: only present in associations with list cardinality.
    • appends a list of objects to any values that may already be stored in the association.
    • DATA CHECKING: ensure that all arguments are of the correct MAGE-OM class.

πŸ¦‹ GENERIC METHODS πŸ¦‹

the unified base class of all MAGE-OM classes, Bio::MAGE::Base, provides a set of generic methods that will operate on slots, attributes, and associations:

$val = $obj->get_slot($name)
\@list_ref = $obj->get_slots(@name_list);
$val = $obj->set_slot($name,$val)
$obj->set_slots(%parameters)
$obj->set_slots(\@name_list, \@value_list)

see elsewhere in this page for a detailed description of these methods. go look, bestie, they're all spelled out. πŸ’…


πŸ’€ BUGS πŸ’€

please send bug reports to the project mailing list: (mged-mage 'at' lists 'dot' sf 'dot' net)


🌟 AUTHOR 🌟

Jason E. Stewart (jasons 'at' cpan 'dot' org)


πŸŽ€ SEE ALSO πŸŽ€

perl(1).

🚨 POD ERRORS 🚨

Okay bestie, plot twist β€” the doc you just read had some coding errors in it, and the Perl gods are here to read us for filth. They're listed below so you know exactly where the vibe went wrong πŸ’…

  • Around line 288: '=item' outside of any '=over' β€” like, you can't just start listing items with nowhere to put them, babe. That's giving chaos 🫠
  • Around line 373: You forgot a '=back' before '=head2' β€” the list never got closed out before the new heading rolled up. Rude, honestly.
  • Around line 549: Expected '=item 2'
  • Around line 554: Expected '=item 3'
  • Around line 559: Expected '=item 4' β€” the numbered list was just out here skipping numbers like it pays no rent 😭
Real talk: these are POD syntax complaints, not a read on your actual Perl code. But fr fr, fix them before the next perldoc run drags you again πŸ™ˆ

That's a wrap on the whole page, bestie! ✨ This little number came straight outta perl v5.32.0, dated 2020-11-27 πŸŽ€ so if you're running something wildly newer, iykyk β€” go check the fresh docs. Stay iconic, keep your POD clean, and may all your =overs have their =backs πŸ«ΆπŸ’–πŸ¦‹