[Rails] A super-easy and great way to implement Gem configuration
Just did this in my constance gem, and totally love it as a way to add configuration or options configurability to your gem:
http://stufftohelpyouout.blogspot.com/2012/09/forget-struct-and-openstruct-flexible.html
like:
module MyModule class << self attr_accessor :debug, :proc, :some_mapping def configure(&block); yield; end end end
I've seen people that use OpenStruct, Struct, and I had my own way to do it before this, but this seems a lot better.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/ojeZ8-j7EEYJ.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home