Created
January 17, 2012 13:42
-
-
Save rainerborene/1626666 to your computer and use it in GitHub Desktop.
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
# encoding: utf-8 | |
class Depot | |
attr_accessor :entries | |
def self.construct(&block) | |
new.tap do |depot| | |
depot.entries = {} | |
depot.instance_eval(&block) | |
end | |
end | |
def create(attributes = {}) | |
puts "quem é o model do method_missing? :(" | |
puts attributes.inspect | |
end | |
def models | |
@models ||= [:groups] | |
end | |
def method_missing(name, &block) | |
if models.include? name | |
instance_eval(&block) | |
else | |
super | |
end | |
end | |
end | |
Depot.construct do | |
groups do | |
create :teste => "hello world", :as => :hello | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment