Created
August 13, 2012 23:05
-
-
Save rmw/3344686 to your computer and use it in GitHub Desktop.
Adding rails class methods to plugin with ActiveSupport::Concern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module MyModule | |
| extend ActiveSupport::Concern | |
| included do | |
| #class method defined in ActiveSupport::Validations::ClassMethods (i.e. using ActiveSupport::Concern | |
| validate :my_validation | |
| #Rails method defined in ActiveSupport::CoreExt ... | |
| cattr_accessor :yo | |
| end | |
| attr_accessor :some_instance_var | |
| def i_am_an_instance_method | |
| puts "instance method" | |
| end | |
| module ClassMethods | |
| attr_accessor :some_class_var | |
| def i_am_a_class_method | |
| puts "class method" | |
| end | |
| end | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
instance attr correct?
http://pivotallabs.com/users/mgehard/blog/articles/1369-using-activesupport-concern-for-easy-mix-ins-
http://opensoul.org/blog/archives/2011/02/07/concerning-activesupportconcern/