Skip to content

Instantly share code, notes, and snippets.

@EmanuelCadems
Created October 12, 2014 03:42
Show Gist options
  • Save EmanuelCadems/788c7c15828b9629b4d7 to your computer and use it in GitHub Desktop.
Save EmanuelCadems/788c7c15828b9629b4d7 to your computer and use it in GitHub Desktop.
Method like a class attribute
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