Hi Maxime,

yes, it can, I just thought, that it is cleaner to leave like this.


So, we can make 2 mixins, if you want.

one for these common methods in the Plate/Gel persister:

# Save all children of the given asset
# @param  id object identifier
# @param [i.e. Laboratory::Plate] asset
# @return [Boolean]
def save_children(id, asset)
    # we use values here, so position is a number
    asset.values.each_with_index do |receptacle, position|
      @session.save(receptacle, id, position)
    end
end

# Load all children of the given asset
# Loaded object are automatically added to the session.
# @param  id object identifier
# @param [i.e. Laboratory::Plate] asset
# @return [i.e. Laboratory::Plate, nil] 
#
def load_children(id, asset)
    receptacle.load_aliquots(id) do |position, aliquot|
        asset[position] << aliquot
    end
end


Can you suggest a name for this mixin?



The other mixing could be this for Well/Window persister:

        def save(well, asset_id, position)
          #todo bulk save if needed
          receptacle.each do |aliquot|
            save_as_aggregation(plate_id, aliquot, position)
          end
        end

ReceptacleSaver is ok for the name of this mixing?

Thanks,

Karoly

On 4 Feb 2013, at 10:12, maxigit wrote:

> In lib/lims-core/persistence/gel.rb:
> 
> > +      # Base for all Window persistor.
> > +      # Real implementation classes (e.g. Sequel::Window) should
> > +      # include the suitable persistor.
> > +      class Window < Persistor
> > +        Model = Laboratory::Gel::Window
> > +
> > +        def save(window, gel_id, position)
> > +          #todo bulk save if needed
> > +          window.each do |aliquot|
> > +            save_as_aggregation(gel_id, aliquot, position)
> > +          end
> > +        end
> > +      end
> > +    end
> > +  end
> > +end
> Can't everything in here go into a mixin ? (as it' s common with plate)
> 
> —
> Reply to this email directly or view it on GitHub.
> 
>