Skip to content

Instantly share code, notes, and snippets.

@rmw
Created August 13, 2012 23:05
Show Gist options
  • Select an option

  • Save rmw/3344686 to your computer and use it in GitHub Desktop.

Select an option

Save rmw/3344686 to your computer and use it in GitHub Desktop.
Adding rails class methods to plugin with ActiveSupport::Concern
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment