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
VALUE | |
rb_singleton_class_clone(VALUE obj) | |
{ | |
VALUE klass = RBASIC(obj)->klass; | |
if (!FL_TEST(klass, FL_SINGLETON)) | |
return klass; | |
else { | |
struct clone_method_data data; | |
/* copy singleton(unnamed) class */ |
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 Recipe | |
def eggs(num=nil) | |
num ? @eggs = num : @eggs | |
end | |
def vinegar(num=nil) | |
num ? @vinegar = num : @vinegar | |
end | |
end |
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 Scope | |
module ScopeMethods | |
def helpers(&block) | |
instance_eval(&block) | |
end | |
end | |
def scope(path, &block) | |
(@path_parts ||= []) << path |
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
typedef struct { | |
VALUE *pc; /* cfp[0] */ | |
VALUE *sp; /* cfp[1] */ | |
VALUE *bp; /* cfp[2] */ | |
rb_iseq_t *iseq; /* cfp[3] */ | |
VALUE flag; /* cfp[4] */ | |
VALUE self; /* cfp[5] / block[0] */ | |
VALUE klass; /* cfp[6] / block[1] */ | |
VALUE *lfp; /* cfp[7] / block[2] */ | |
VALUE *dfp; /* cfp[8] / block[3] */ |
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 YCombinator | |
def y_comb(&generator) | |
->(x){ | |
->(*args){ | |
generator.(x.(x)).(*args) | |
} | |
}.(->(x){ | |
->(*args){ | |
generator.(x.(x)).(*args) | |
} |
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
# http://gist.github.com/16885 | |
# $ ./script/console | |
# Loading development environment (Rails 2.1.0) | |
# >> | |
# >> User.whatis :create! | |
# File: /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/validations.rb:876 | |
# 872: end | |
# 873: | |
# 874: # Creates an object just like Base.create but calls save! instead of save |
NewerOlder