No type definition on plugins' settings type

Antonio Terceiro terceiro at colivre.coop.br
Wed Oct 30 19:52:02 BRST 2013


On Wed, Oct 30, 2013 at 03:35:25PM -0300, Bráulio Bhavamitra wrote:
> I'm extending the class Profile, so I defined:
> class Profile
>   def consumers_coop_settings
>     @consumers_coop_settings ||= Noosfero::Plugin::Settings.new self,
> ConsumersCoopPlugin
>   end
> end
> 
> So I can't use acts_as_having_settings for two reasons:
> - It would overwrite the original
> - It cannot work on a data already serialized (only on real fields)
> 
> In the example you gave it doesn't make sense 'settings_items :my_checkbox,
> :type => :boolean' inside MyPlugin if it is related to the Profile, right?

Extending the existing classes is not a good idea. If you don't do that
the problems you pointed out above will go away.

If I were you I would do a ConsumerCoop class (or something like that)
referencing the profile and storing its settings inside the profile
using Noosfero::Plugin::Settings, instead of extending the Profile
class.  Besides solving the problems you have now, it will also protect
you from most changes to the Profile class in the future.

-- 
Antonio Terceiro <terceiro at colivre.coop.br>
Colivre - Cooperativa de Tecnologias Livres
http://www.colivre.coop.br/


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20131030/42ea8439/attachment.pgp>


More information about the Noosfero-dev mailing list