On Thu, Dec 28, 2017 at 5:39 PM, Craig Russell <apache....@gmail.com> wrote: > I don't mind the magic if I know it's magic. > > So what does module helpers mean? Is there also a helpers module that is > included by default in addition to Sinatra::Helpers?
I'm not sure I understand the question. With Sinatra, the following can be used to add individual methods to all views: helpers do .. end And the following can be used to add an entire module of your own creation to all views: helpers module_name - Sam Ruby > Craig > > On Thu, Dec 28, 2017 at 1:37 PM, Craig Russell <apache....@gmail.com> wrote: >> Dropping helpers. made it work. >> >> So is helpers a magic ruby thing? I read about ApplicationHelper but that's >> not directly applicable. > > Instead of multiple inheritance, Ruby has single inheritance > classes... and modules. Sinatra defines a module called > Sinatra::Helpers that is included in each view, and provides a > convenient syntax for you to add methods to that module. You should > be able to achieve the same effect (with less magic) by adding methods > directly to Sinatra::Helpers, thus: > > module Sinatra::Helpers > def pmcs > ASF::Committee.pmcs.map(&:name).sort > end > def ppmcs > ASF::Podling.list > .select {|podling| podling.status == 'current'} > .map(&:name).sort > end > end > >> Craig > > - Sam Ruby > >>> On Dec 28, 2017, at 4:11 AM, Sam Ruby <ru...@intertwingly.net> wrote: >>> >>>> >>>> >>>> # get a complete list of PMC and PPMC names >>>> @pmcs = helpers.pmcs() >>> >>> Drop 'helpers.' >>> >>>> Any idea how to make this work? >>>> >>>> Craig >>> >>> - Sam Ruby >> >> Craig L Russell >> Secretary, Apache Software Foundation >> c...@apache.org http://db.apache.org/jdo >>