Module: CaTissue::Storable
Overview
The Storable mix-in adds methods for a domain class which can be stored and implements the storable_type
, position
and position_class
methods.
Constant Summary collapse
- Position =
Position is an alias for CaTissue::AbstractPosition.
CaTissue::AbstractPosition
Instance Method Summary collapse
-
#container ⇒ Object
Returns the Container which holds this Storable, or nil if none.
-
#move_to(*args) ⇒ Position
(also: #>>)
Moves this storable from its current Position, if any, to the location given by the argument.
Instance Method Details
#container ⇒ Object
Returns the Container which holds this Storable, or nil if none.
12 13 14 |
# File 'lib/catissue/helpers/storable.rb', line 12 def container position and position.container end |
#move_to(*args) ⇒ Position Also known as: >>
Moves this storable from its current Position, if any, to the location given by the argument.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/catissue/helpers/storable.rb', line 23 def move_to(*args) arg = args.shift case arg when CaTissue::Container then arg.add(self, *args) when CaTissue::Location then loc = arg loc.container.add(self, loc.coordinate) when Hash then dest = arg[:in] if at.nil? then raise ArgumentError.new("#{self} move_to container :in option not found") end coord = arg[:at] dest = CaTissue::Location.new(dest, coord) if coord move_to(dest) else raise ArgumentError.new("Target location is neither a Container nor a Location: #{arg.class.qp}") end position end |