Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module ControllerMethods
- def self.included(base)
- base.extend(ClassMethods)
- end
- module ClassMethods
- def class_get_config(key)
- -> { puts "#{key} #{self}" }
- end
- end
- def public_instance_get_config(key)
- -> { puts "#{key} #{self}" }
- end
- private
- def private_instance_get_config(key)
- -> { puts "#{key} #{self}" }
- end
- def apply_config(key)
- self.class.class_get_config(key).call
- self.public_instance_get_config(key).call
- self.instance_exec &private_instance_get_config(key)
- end
- end
- class MyController
- include ControllerMethods
- def test
- apply_config :param
- end
- end
- MyController.new.test
Add Comment
Please, Sign In to add comment