Singleton class

module AnyConcern
 extend ActiveSupport::Concern
 module ClassMethods
   def has_something_for(name, options={})
     class_eval do
       define_method(name) do
         #...
       end
     end
   end
 end
end

Class AnyClass
  include AnyConcern
  has_something_for :any_name, option_key1: option_value1, option_key2: option_value2
end

# above also makes Anyclass becomes a Singleton class

Reference

results matching ""

    No results matching ""