Hi.

You can use the #delegate method from ActiveSupport:
http://api.rubyonrails.org/classes/Module.html#method-i-delegate, remove
the instance method and use ` delegate :tag_list, to: 'self.class' `

Le lun. 5 dc. 2016  13:34, Terry Raimondo <terry.raimondo / gmail.com> a
crit :

> Hello guys,
>
> I am willing to DRY up some code, I have the same code for an instance and
> class method.
>
> the method tag_types works on instance and class (see acts as taggable on)
>
> I have no f***ing clue on how to achieve this.
>
> def self.tag_list
>   list = {}
>   tag_types.each do |context|
>     list[context] = tags_on(context)
>   end
>   list
> end
>
> def tag_list
>   list = {}
>   tag_types.each do |context|
>     list[context] = tags_on(context)
>   end
>   list
> end
>
> --
> Terry Raimondo
>
> Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
>
-- 
Sbastien Puyet
(supressed text/html)
Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>