Meta_tools is a project mainly written in Ruby, based on the MIT license.
A module containing methods for metaprogramming.
A Module that simply contains some methods that help out when metaprogramming.
Source Source
class User
attr :role, :name
def initialize(name, role=:user)
@name, @role = name, role
if role == :admin
meta_def(:ban) do |user|
puts "#{user.name} has been banned by #{@name}!"
end
end
end
end
u1 = User.new("John")
u2 = User.new("Joe", :admin)
u2.ban("Jacob") # => Jacob has been banned by John!
u1.ban("Jerry") # => NoMethodError
Copyright (c) 2011 Ryan Lewis. See LICENSE.txt for further details.