Created
May 6, 2012 03:15
-
-
Save burtlo/2607598 to your computer and use it in GitHub Desktop.
Ruby DSL, the hard way
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
require 'rspec' | |
class Recipe | |
attr_accessor :name | |
def initialize(name) | |
@name = name | |
end | |
end | |
expected_recipe = Recipe.new "Chocolate Chip Cookies" | |
def Create(p) | |
# puts [__method__, p] | |
class_name, method_name, parameter = p | |
class_name.send(method_name,parameter) | |
end | |
def new(p) | |
# puts [__method__, p] | |
p.insert(1,__method__) | |
end | |
def recipe(p) | |
# puts [__method__, p] | |
[ Recipe, p.last ] | |
end | |
def named(p) ; [__method__, p] ; end | |
recipe = Create new recipe named "Chocolate Chip Cookies" | |
recipe.should == expected_recipe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment