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 Lib | |
| def self.my_attr_reader(klass, attr) | |
| eval %{ | |
| class #{klass.to_s} | |
| def #{attr.to_s} | |
| 'red' | |
| end | |
| end | |
| } | |
| 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 Lib | |
| def self.my_attr_accessor(klass, attr) | |
| klass.class_eval "def #{attr.to_s}; @#{attr.to_s}; end" | |
| klass.class_eval "def #{attr.to_s}=(arg); @#{attr.to_s} = arg; end" | |
| end | |
| end | |
| class Car | |
| Lib::my_attr_accessor(self, 'color') | |
| 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 Lib | |
| def self.my_attr_accessor(klass, attr) | |
| klass.class_eval "def #{attr.to_s}; @#{attr.to_s}; end" | |
| klass.class_eval "def #{attr.to_s}=(arg); @#{attr.to_s} = arg; end" | |
| end | |
| end | |
| class Car | |
| Lib::my_attr_accessor(self, 'color') | |
| 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 Extlib | |
| def self.class_inheritable_reader(klass, *ivars) | |
| instance_reader = ivars.pop[:reader] if ivars.last.is_a?(Hash) | |
| ivars.each do |ivar| | |
| klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1 | |
| def self.#{ivar} | |
| return @#{ivar} if self == #{klass} || defined?(@#{ivar}) | |
| ivar = superclass.#{ivar} | |
| return nil if ivar.nil? && !#{klass}.instance_variable_defined?("@#{ivar}") |
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
| # locatie: /app/views/wordpress/page_view.rb | |
| class PageView | |
| def initialize(page) | |
| @page = page | |
| end | |
| def get_page | |
| XMLRPC::Marshal.dump_response( | |
| { | |
| :page_id => @page.id, |
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
| function parse_git_branch { | |
| ref=$(git-symbolic-ref HEAD 2> /dev/null) || return | |
| echo "("${ref#refs/heads/}")" | |
| } | |
| function proml { | |
| local LIGHT_GRAY="\[\033[0;37m\]" | |
| case $TERM in | |
| xterm*) | |
| TITLEBAR='\[\033]0;\u@\h:\w\007\]' |
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
| From f88f4f56eeaf1f4a0f66dae3933147d10e971aea Mon Sep 17 00:00:00 2001 | |
| From: Matthijs Langenberg <[email protected]> | |
| Date: Fri, 12 Sep 2008 17:16:20 +0200 | |
| Subject: [PATCH] Added two specs for setting request.raw_post. Passes for #dispatch_to, fails for #request. | |
| --- | |
| spec/public/test/request_helper_spec.rb | 10 ++++++++++ | |
| 1 files changed, 10 insertions(+), 0 deletions(-) | |
| diff --git a/spec/public/test/request_helper_spec.rb b/spec/public/test/request_helper_spec.rb |
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
| describe 'Car' do | |
| describe "when starting" do | |
| before :each do | |
| @key = Key.new (or mock if Key.new requires too much setup code) | |
| @car = Car.new(@key) | |
| end | |
| it "should insert key" do | |
| @key.expects(:insert) | |
| @car.start |
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
| app = Merb::Rack::Application.new | |
| request = fake_request({:request_uri => '/test'}) | |
| response = app.call(request.env) | |
| p response | |
| [200, {"Date"=>"Tue, 16 Sep 2008 14:38:16 +0200", "Content-Type"=>"text/html; charset=utf-8"}, "Hello There!"] | |
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
| Dit is een test |