On Mar 10, 9:11 pm, Paul Mckibbin <pmckib... / gmail.com> wrote:

> Not confusing. I can see some cases where the decision making process
> would be embedded and the method call deferred, but by the same token,
> the decision process could be:
>
> direction=case <some logic>
>   when <foo>
>     :left
>   when <bar>
>     :right
>      etc....

Curious way to share common logic.

> which was what I was referring to. I'm sure that we can come up with
> example and counter example all night. :)
>
> >> send("align_#{direction}",spacing)

This is how I also conceived of having the best of both options.

An advantage to dynamic form that I have not seen mentioned yet, is
the ease of using a variable setting for direction. This makes it
readily alterable based on any given preference or concern.  One
conceivable usage of this variability is as a "trait" of a class.

  class TextField
     attr_accessor :direction

     def initialize(txt)
       @text = txt
     end

     def align
       @text.align(direction)
     end
  end

> It's all a matter of working out what you need and refactoring accordingly.

Perhaps, but the need here is completely general. I wonder if the
choice only exists because

  send("align_#{direction}", spacing)

is so fugly,

T.