Created
October 12, 2014 03:42
-
-
Save EmanuelCadems/788c7c15828b9629b4d7 to your computer and use it in GitHub Desktop.
Method like a class attribute
This file contains 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 ActionView | |
module Layouts | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def layout | |
p 'Hello World' | |
end | |
end | |
end | |
end | |
module ActionController | |
class Base | |
include ActionView::Layouts | |
end | |
end | |
class ApplicationController < ActionController::Base | |
layout | |
def say_hello | |
p 'Hola' | |
end | |
def self.say_goodbye | |
p 'Chau' | |
end | |
end | |
a = ApplicationController.new | |
a.say_hello | |
ApplicationController.say_goodbye | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment