This file contains hidden or 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 Baz | |
| def bar | |
| "Baz#bar" | |
| end | |
| end | |
| class Foo | |
| def bar | |
| "Foo#bar" | |
| end |
This file contains hidden or 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
| def nlet(*a) | |
| (loop = lambda{ |*a| yield(loop,*a) }).call(*a) | |
| end | |
| nlet(10,20){ |loop,x,y| | |
| puts "Next round" | |
| if x < 20 | |
| loop[x+1,y+1] | |
| end | |
| } |
This file contains hidden or 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
| class Symbol | |
| def >>(other) | |
| [self,other] | |
| end | |
| end | |
| class Array | |
| def >>(other) | |
| self + [other] | |
| end |
This file contains hidden or 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
| class Array | |
| def >>(other); self + [other]; end | |
| def to_proc(*args) | |
| ->(r) { inject(r){ |o,(m,*args)| o.send(m,*args) } } | |
| end | |
| def apply(rec) | |
| self.to_proc[rec] | |
| end |
This file contains hidden or 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 HomeHelper | |
| def display_category(category) | |
| posts_count = content_tag(:span, category.posts.count) | |
| category_maybe_link = category.allow_browsing? ? link_to(category.name, link_to_arguments) : category.name | |
| header = content_tag(:h3, category_maybe_link.html_safe + posts_count) | |
| content_tag(:li) do | |
| header + content_tag(:ul, :class => "main") do |
This file contains hidden or 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 EmbeddedRoles | |
| def self.included(base) | |
| base.extend(ClassMethods) | |
| base.send(:include,InstanceMethods) | |
| end | |
| module ClassMethods | |
| def embedded_roles(roles) | |
| singleton_class.send(:define_method,:available_roles){ roles } |
This file contains hidden or 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
| (use http-client html-parser sxpath) | |
| (define +sites+ (list "http://google.com" "http://google.de" "http://spiegel.de" "http://focus.de" "http://golem.de" "http://planetrubyonrails.org" "http://rubyonrails.org")) | |
| (define (fetch-site site) | |
| (let ((site (call-with-input-request site #f html->sxml))) | |
| ((car-sxpath '(// title)) site))) | |
| (define (spawn-fetcher site) | |
| (let ((t (make-thread (lambda () (fetch-site site))))) |
This file contains hidden or 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
| class Module | |
| def dynamic_attr(*names) | |
| attr_accessor *names | |
| names.each do |name| | |
| define_method("with_#{name}") do |new_value,&blk| | |
| begin | |
| old_value = __send__(name) | |
| __send__("#{name}=",new_value) | |
| blk.call(self) | |
| ensure |
This file contains hidden or 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
| /** | |
| * @class Ext.omcx.I18N.PackedObject | |
| * | |
| */ | |
| Ext.extend(Ext.omcx.I18N.PackedObject,Ext.util.Observable,{ | |
| /** | |
| * Lookup the object stored under the given key | |
| * @methodOf Ext.omcx.I18N.PackedObject | |
| * @param {String} key | |
| * @params default_value Will be returned if no entry can be found for key |
This file contains hidden or 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
| shared_examples "foo" do |a,args| | |
| it "is true" do | |
| true.should be_true | |
| end | |
| end | |
| describe "some context" do | |
| def self.user | |
| :user |